xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/relocations-no-symtab.test (revision 98a4289810ba49cea6f9a9be6d902e72f0c0d0e7)
1a795bd96SGeorgii Rymar## Check that we can copy an object that has a relocation
2a795bd96SGeorgii Rymar## with a symbol index of 0 even when there is no symbol table.
3a795bd96SGeorgii Rymar
4a795bd96SGeorgii Rymar# RUN: yaml2obj --docnum=1 %s -o %t1
5a795bd96SGeorgii Rymar# RUN: llvm-objcopy %t1 %t2
6a795bd96SGeorgii Rymar# RUN: llvm-readobj --relocations %t2 | FileCheck %s
7a795bd96SGeorgii Rymar
8a795bd96SGeorgii Rymar# CHECK:     Relocations [
9a795bd96SGeorgii Rymar# CHECK-NEXT:  Section {{.*}} .rel.text {
10*98a42898SGeorgii Rymar# CHECK-NEXT:    0x1000 R_X86_64_RELATIVE -
11a795bd96SGeorgii Rymar# CHECK-NEXT:  }
12a795bd96SGeorgii Rymar# CHECK-NEXT:]
13a795bd96SGeorgii Rymar
14a795bd96SGeorgii Rymar--- !ELF
15a795bd96SGeorgii RymarFileHeader:
16a795bd96SGeorgii Rymar  Class:   ELFCLASS64
17a795bd96SGeorgii Rymar  Data:    ELFDATA2LSB
18a795bd96SGeorgii Rymar  Type:    ET_REL
19a795bd96SGeorgii Rymar  Machine: EM_X86_64
20a795bd96SGeorgii RymarSections:
21a795bd96SGeorgii Rymar  - Name:  .text
22a795bd96SGeorgii Rymar    Type:  SHT_PROGBITS
23a795bd96SGeorgii Rymar    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
24a795bd96SGeorgii Rymar  - Name:  .rel.text
25a795bd96SGeorgii Rymar    Type:  SHT_REL
26a795bd96SGeorgii Rymar    Info:  .text
27a795bd96SGeorgii Rymar    Relocations:
28a795bd96SGeorgii Rymar      - Offset: 0x1000
29a795bd96SGeorgii Rymar        Type:   R_X86_64_RELATIVE
30a795bd96SGeorgii Rymar
31a795bd96SGeorgii Rymar## Check that we report an error when a relocation refers to a
32a795bd96SGeorgii Rymar## non-zero symbol index but there is no symbol table.
33a795bd96SGeorgii Rymar
34a795bd96SGeorgii Rymar# RUN: yaml2obj --docnum=2 %s -o %t3
35a795bd96SGeorgii Rymar# RUN: not llvm-objcopy %t3 /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
36a795bd96SGeorgii Rymar
37a795bd96SGeorgii Rymar# ERR: error: '.rel.text': relocation references symbol with index 1, but there is no symbol table
38a795bd96SGeorgii Rymar
39a795bd96SGeorgii Rymar--- !ELF
40a795bd96SGeorgii RymarFileHeader:
41a795bd96SGeorgii Rymar  Class:   ELFCLASS64
42a795bd96SGeorgii Rymar  Data:    ELFDATA2LSB
43a795bd96SGeorgii Rymar  Type:    ET_REL
44a795bd96SGeorgii Rymar  Machine: EM_X86_64
45a795bd96SGeorgii RymarSections:
46a795bd96SGeorgii Rymar  - Name:  .text
47a795bd96SGeorgii Rymar    Type:  SHT_PROGBITS
48a795bd96SGeorgii Rymar    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
49a795bd96SGeorgii Rymar  - Name:  .rel.text
50a795bd96SGeorgii Rymar    Type:  SHT_REL
51a795bd96SGeorgii Rymar    Info:  .text
52a795bd96SGeorgii Rymar    Relocations:
53a795bd96SGeorgii Rymar      - Offset: 0x1000
54a795bd96SGeorgii Rymar        Symbol: 1
55a795bd96SGeorgii Rymar        Type:   R_X86_64_NONE
56