# RUN: yaml2obj --docnum=1 %s -o %t
# RUN: llvm-objdump -r %t | FileCheck %s --strict-whitespace --match-full-lines
# CHECK:RELOCATION RECORDS FOR [.text]:
# CHECK-NEXT:OFFSET TYPE VALUE
# CHECK-NEXT:0000000000000001 R_X86_64_32 g1+0x1
# CHECK-NEXT:0000000000000002 R_X86_64_64 l1+0x2
# CHECK-NEXT:0000000000000000 R_X86_64_32S g1-0x1
# CHECK-NEXT:0000000000000004 R_X86_64_32S .text-0x8000000000000000
#CHECK-EMPTY:
# CHECK-NEXT:RELOCATION RECORDS FOR [nonalloc]:
# CHECK-NEXT:OFFSET TYPE VALUE
# CHECK-NEXT:0000000000000010 R_X86_64_64 g1+0x1
# CHECK-NEXT:0000000000000020 R_X86_64_64 g2+0x2
# CHECK-NEXT:0000000000000030 R_X86_64_64 *ABS*
# CHECK-NOT:{{.}}
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "0000000000000000"
Flags: [SHF_ALLOC]
- Name: .crel.text
Type: SHT_CREL
Info: .text
Link: .symtab
Relocations:
- Offset: 0x1
Symbol: g1
Type: R_X86_64_32
Addend: 1
- Offset: 0x2
Symbol: l1
Type: R_X86_64_64
Addend: 2
- Offset: 0x0
Symbol: g1
Type: R_X86_64_32S
Addend: 0xffffffffffffffff
- Offset: 0x4
Symbol: .text
Type: R_X86_64_32S
Addend: 0x8000000000000000
- Name: nonalloc
Type: SHT_PROGBITS
Size: 0x30
- Name: .crelnonalloc
Type: SHT_CREL
Info: nonalloc
Link: .symtab
Relocations:
- Offset: 0x10
Symbol: g1
Type: R_X86_64_64
Addend: 1
- Offset: 0x20
Symbol: g2
Type: R_X86_64_64
Addend: 2
- Offset: 0x30
Symbol: 0
Type: R_X86_64_64
Symbols:
- Name: .text
Type: STT_SECTION
Section: .text
- Name: l1
- Name: g1
Section: .text
Value: 0x0
Size: 4
Binding: STB_GLOBAL
- Name: g2
Binding: STB_GLOBAL
## Check relocation formatting on ELFCLASS32 as well.
# RUN: yaml2obj --docnum=2 %s > %t2
# RUN: llvm-objdump -r %t2 | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines
# ELF32:RELOCATION RECORDS FOR [.text]:
# ELF32-NEXT:OFFSET TYPE VALUE
# ELF32-NEXT:00000008 R_ARM_REL32 l1+0x1
# ELF32-NEXT:00000004 R_ARM_ABS32 g1
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_REL
Machine: EM_ARM
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x10
- Name: .crel.text
Type: SHT_CREL
Info: .text
Link: .symtab
Relocations:
- Offset: 0x8
Symbol: l1
Type: R_ARM_REL32
Addend: 1
- Offset: 0x4
Symbol: g1
Type: R_ARM_ABS32
Symbols:
- Name: l1
- Name: g1
Binding: STB_GLOBAL
## Check CREL with implicit addends.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-objdump -r %t3 | FileCheck %s --check-prefix=IMPLICIT --strict-whitespace --match-full-lines
# IMPLICIT:RELOCATION RECORDS FOR [.data]:
# IMPLICIT-NEXT:OFFSET TYPE VALUE
# IMPLICIT-NEXT:000000000000001f R_X86_64_32 g1
# IMPLICIT-NEXT:000000000000003f R_X86_64_64 g1
# IMPLICIT-NEXT:0000000000000000 R_X86_64_32S l1
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .data
Type: SHT_PROGBITS
- Name: .crel.data
Type: SHT_CREL
Flags: [ SHF_INFO_LINK ]
Link: .symtab
Info: .data
Content: 187f030a82017787feffffffffffffff077f0a
Symbols:
- Name: .text
Type: STT_SECTION
Section: .text
- Name: l1
Section: .text
- Name: g1
Section: .text
Binding: STB_GLOBAL
## Test errors.
# RUN: yaml2obj --docnum=4 %s -o %t.err
# RUN: llvm-objdump -r %t.err 2>&1 | FileCheck %s --check-prefix=ERR -DFILE=%t.err
# ERR:RELOCATION RECORDS FOR [.data]:
# ERR-NEXT:OFFSET TYPE VALUE
# ERR-NEXT:warning: '[[FILE]]': unable to decode LEB128 at offset 0x00000000: malformed uleb128, extends past end
# ERR-NOT:{{.}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .data
Type: SHT_PROGBITS
- Name: .crel.data
Type: SHT_CREL
Flags: []
Link: .symtab
Info: .data
Symbols:
- Name: .text
Type: STT_SECTION
Section: .text
# RUN: yaml2obj --docnum=5 %s -o %t.err2
# RUN: llvm-objdump -r %t.err2 2>&1 | FileCheck %s --check-prefix=ERR2 -DFILE=%t.err2
# ERR2:RELOCATION RECORDS FOR [.data]:
# ERR2-NEXT:OFFSET TYPE VALUE
# ERR2-NEXT:warning: '[[FILE]]': unexpected end of data at offset 0x1 while reading [0x1, 0x2)
# ERR2-NOT:{{.}}
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_REL
Machine: EM_ARM
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .data
Type: SHT_PROGBITS
- Name: .crel.data
Type: SHT_CREL
Flags: []
Link: .symtab
Info: .data
Content: 08
Symbols:
- Name: .text
Type: STT_SECTION
Section: .text