194 lines
4.5 KiB
Plaintext
194 lines
4.5 KiB
Plaintext
|
# RUN: yaml2obj --docnum=1 %s -o %t
|
||
|
# RUN: llvm-objdump --reloc %t > %t1
|
||
|
# RUN: llvm-objdump -r %t > %t2
|
||
|
# RUN: cmp %t1 %t2
|
||
|
# RUN: FileCheck %s --input-file=%t1 --strict-whitespace --match-full-lines
|
||
|
|
||
|
# CHECK:RELOCATION RECORDS FOR [.text]:
|
||
|
# CHECK-NEXT:OFFSET TYPE VALUE
|
||
|
# 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+0x1
|
||
|
# CHECK-NEXT:0000000000000001 R_X86_64_32S glob2+0x2
|
||
|
# CHECK-NEXT:0000000000000002 R_X86_64_64 loc1+0x3
|
||
|
|
||
|
--- !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 -o %t2
|
||
|
# RUN: not llvm-objdump --reloc %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=ERR
|
||
|
# ERR: error: '[[FILE]]': section (1): unable to get a relocation target: invalid section index: 255
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Machine: EM_X86_64
|
||
|
Sections:
|
||
|
- Name: .rela.foo
|
||
|
Type: SHT_RELA
|
||
|
Info: 0xFF
|
||
|
Relocations:
|
||
|
- Offset: 0x1
|
||
|
Type: R_X86_64_NONE
|
||
|
|
||
|
## Check ranges of addends being displayed in a dump of relocations.
|
||
|
# RUN: yaml2obj --docnum=3 %s -o %t3
|
||
|
# RUN: llvm-objdump -r %t3 | FileCheck %s --check-prefix=ADDENDS
|
||
|
|
||
|
# ADDENDS: RELOCATION RECORDS FOR [.text]:
|
||
|
# ADDENDS: R_X86_64_64 glob-0x8000000000000000
|
||
|
# ADDENDS: R_X86_64_64 glob+0x7fffffffffffffff
|
||
|
# ADDENDS: R_X86_64_64 glob-0x1
|
||
|
# ADDENDS: R_X86_64_64 glob+0x12345678
|
||
|
# ADDENDS: R_X86_64_64 glob{{$}}
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Machine: EM_X86_64
|
||
|
Sections:
|
||
|
- Name: .text
|
||
|
Type: SHT_PROGBITS
|
||
|
Size: 8
|
||
|
Flags: [SHF_EXECINSTR,SHF_ALLOC]
|
||
|
- Name: .rela.text
|
||
|
Type: SHT_RELA
|
||
|
Info: .text
|
||
|
Relocations:
|
||
|
- Offset: 0x0
|
||
|
Addend: -9223372036854775808
|
||
|
Symbol: glob
|
||
|
Type: R_X86_64_64
|
||
|
- Offset: 0x1
|
||
|
Symbol: glob
|
||
|
Type: R_X86_64_64
|
||
|
Addend: 9223372036854775807
|
||
|
- Offset: 0x2
|
||
|
Symbol: glob
|
||
|
Type: R_X86_64_64
|
||
|
Addend: -1
|
||
|
- Offset: 0x3
|
||
|
Symbol: glob
|
||
|
Type: R_X86_64_64
|
||
|
Addend: 0x12345678
|
||
|
- Offset: 0x4
|
||
|
Symbol: glob
|
||
|
Type: R_X86_64_64
|
||
|
Addend: 0
|
||
|
Symbols:
|
||
|
- Name: glob
|
||
|
Section: .text
|
||
|
Value: 0x0
|
||
|
Size: 0
|
||
|
Binding: STB_GLOBAL
|
||
|
|
||
|
## Check relocation formatting on 32 bit as well to verify the formatting is correct.
|
||
|
# RUN: yaml2obj --docnum=4 %s > %t4
|
||
|
# RUN: llvm-objdump -r %t4 | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines
|
||
|
|
||
|
# ELF32:RELOCATION RECORDS FOR [.text]:
|
||
|
# ELF32-NEXT:OFFSET TYPE VALUE
|
||
|
# ELF32-NEXT:00000001 R_386_32 global
|
||
|
# ELF32-NEXT:00000002 R_386_PC32 local
|
||
|
# ELF32-NEXT:00000001 R_386_NONE global+0x1
|
||
|
# ELF32-NEXT:00000002 R_386_NONE local+0x2
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS32
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Machine: EM_386
|
||
|
Sections:
|
||
|
- Name: .text
|
||
|
Type: SHT_PROGBITS
|
||
|
- Name: .rel.text
|
||
|
Type: SHT_REL
|
||
|
Info: .text
|
||
|
Relocations:
|
||
|
- Offset: 0x1
|
||
|
Symbol: global
|
||
|
Type: R_386_32
|
||
|
- Offset: 0x2
|
||
|
Symbol: local
|
||
|
Type: R_386_PC32
|
||
|
- Name: .rela.text
|
||
|
Type: SHT_RELA
|
||
|
Info: .text
|
||
|
Relocations:
|
||
|
- Offset: 0x1
|
||
|
Addend: 1
|
||
|
Symbol: global
|
||
|
Type: R_386_NONE
|
||
|
- Offset: 0x2
|
||
|
Addend: 2
|
||
|
Symbol: local
|
||
|
Type: R_386_NONE
|
||
|
Symbols:
|
||
|
- Name: local
|
||
|
- Name: global
|
||
|
Binding: STB_GLOBAL
|