Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/relocations-no-symtab.test

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