Files
llvm/test/tools/llvm-objdump/relocations-elf.test
T
George Rimar f4cd658f2d [llvm-objdump] - Print relocation record in a GNU format.
This fixes the https://bugs.llvm.org/show_bug.cgi?id=41355.

Previously with -r we printed relocation section name instead of the target section name.
It was like this: "RELOCATION RECORDS FOR [.rel.text]"
Now it is: "RELOCATION RECORDS FOR [.text]"

Also when relocation target section has more than one relocation section,
we did not combine the output. Now we do.

Differential revision: https://reviews.llvm.org/D61312

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360143 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-07 13:14:18 +00:00

94 lines
2.0 KiB
Plaintext

# RUN: yaml2obj --docnum=1 %s > %t
# RUN: llvm-objdump --reloc %t > %t1
# RUN: llvm-objdump -r %t > %t2
# RUN: cmp %t1 %t2
# RUN: FileCheck %s --input-file=%t1
# CHECK: RELOCATION RECORDS FOR [.text]:
# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1
# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2
# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1
# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1+1
# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2+2
# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1+3
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "0000000000000000"
AddressAlign: 16
Flags: [SHF_ALLOC]
- Name: .rel.text
Type: SHT_REL
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0x1
Symbol: glob1
Type: R_X86_64_32
- Offset: 0x1
Symbol: glob2
Type: R_X86_64_32S
- Offset: 0x2
Symbol: loc1
Type: R_X86_64_64
- Name: .rela.text
Type: SHT_RELA
Link: .symtab
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0x1
Addend: 1
Symbol: glob1
Type: R_X86_64_32
- Offset: 0x1
Addend: 2
Symbol: glob2
Type: R_X86_64_32S
- Offset: 0x2
Addend: 3
Symbol: loc1
Type: R_X86_64_64
Symbols:
- Name: loc1
- Name: loc2
- Name: glob1
Section: .text
Value: 0x0
Size: 4
Binding: STB_GLOBAL
- Name: glob2
Binding: STB_GLOBAL
## Check we report an error if the relocated section identified by the
## sh_info field of a relocation section is invalid.
# RUN: yaml2obj --docnum=2 %s > %t2
# RUN: not llvm-objdump --reloc %t2 2>&1 | FileCheck %s --check-prefix=ERR
# ERR: LLVM ERROR: Invalid data was encountered while parsing the file
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .rela.foo
Type: SHT_RELA
Link: .symtab
Info: 0x255
Relocations:
- Offset: 0x1
Type: R_X86_64_NONE