diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2014-04-11 04:13:39 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2014-04-11 04:13:39 +0000 |
commit | eb0c9094acd5f5a28c0adafb1784797d1d7a4e2d (patch) | |
tree | d94849c02e0a4a546c075081bb4ace35f0ea2937 /test/Object/yaml2obj-elf-rel.yaml | |
parent | 77cf856e56dc568ebe760e7de820323fdcf825a4 (diff) | |
download | llvm-eb0c9094acd5f5a28c0adafb1784797d1d7a4e2d.tar.gz llvm-eb0c9094acd5f5a28c0adafb1784797d1d7a4e2d.tar.bz2 llvm-eb0c9094acd5f5a28c0adafb1784797d1d7a4e2d.tar.xz |
[yaml2obj][ELF] ELF Relocations Support.
The patch implements support for both relocation record formats: Elf_Rel
and Elf_Rela. It is possible to define relocation against symbol only.
Relocations against sections will be implemented later. Now yaml2obj
recognizes X86_64, MIPS and Hexagon relocation types.
Example of relocation section specification:
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_MIPS_32
- Offset: 0x2
Symbol: glob2
Type: R_MIPS_CALL16
The patch reviewed by Michael Spencer, Sean Silva, Shankar Easwaran.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Object/yaml2obj-elf-rel.yaml')
-rw-r--r-- | test/Object/yaml2obj-elf-rel.yaml | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/test/Object/yaml2obj-elf-rel.yaml b/test/Object/yaml2obj-elf-rel.yaml new file mode 100644 index 0000000000..121a533b8c --- /dev/null +++ b/test/Object/yaml2obj-elf-rel.yaml @@ -0,0 +1,118 @@ +# RUN: yaml2obj -format=elf %s | llvm-readobj -sections -relocations - | FileCheck %s + +!ELF +FileHeader: !FileHeader + Class: ELFCLASS32 + Data: ELFDATA2MSB + Type: ET_REL + Machine: EM_MIPS + +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_MIPS_32 + - Offset: 0x1 + Symbol: glob2 + Type: R_MIPS_CALL16 + - Offset: 0x2 + Symbol: loc1 + Type: R_MIPS_LO16 + +- Name: .rela.text + Type: SHT_RELA + Link: .symtab + Info: .text + AddressAlign: 4 + Relocations: + - Offset: 0x1 + Addend: 1 + Symbol: glob1 + Type: R_MIPS_32 + - Offset: 0x1 + Addend: 2 + Symbol: glob2 + Type: R_MIPS_CALL16 + - Offset: 0x2 + Addend: 3 + Symbol: loc1 + Type: R_MIPS_LO16 + +Symbols: + Local: + - Name: loc1 + - Name: loc2 + Global: + - Name: glob1 + Section: .text + Value: 0x0 + Size: 4 + - Name: glob2 + Weak: + - Name: weak1 + +# CHECK: Section { +# CHECK-NEXT: Index: 0 +# CHECK: } +# CHECK: Section { +# CHECK-NEXT: Index: 1 +# CHECK-NEXT: Name: .text (1) +# CHECK: } +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Name: .rel.text (7) +# CHECK-NEXT: Type: SHT_REL (0x9) +# CHECK-NEXT: Flags [ (0x0) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x160 +# CHECK-NEXT: Size: 24 +# CHECK-NEXT: Link: 4 +# CHECK-NEXT: Info: 1 +# CHECK-NEXT: AddressAlignment: 4 +# CHECK-NEXT: EntrySize: 8 +# CHECK-NEXT: } +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 3 +# CHECK-NEXT: Name: .rela.text (17) +# CHECK-NEXT: Type: SHT_RELA (0x4) +# CHECK-NEXT: Flags [ (0x0) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x180 +# CHECK-NEXT: Size: 36 +# CHECK-NEXT: Link: 4 +# CHECK-NEXT: Info: 1 +# CHECK-NEXT: AddressAlignment: 4 +# CHECK-NEXT: EntrySize: 12 +# CHECK-NEXT: } +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 4 +# CHECK-NEXT: Name: .symtab (28) +# CHECK: } +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 5 +# CHECK-NEXT: Name: .strtab (36) +# CHECK: } +# CHECK: Relocations [ +# CHECK-NEXT: Section (2) .rel.text { +# CHECK-NEXT: 0x1 R_MIPS_32 glob1 0x0 +# CHECK-NEXT: 0x1 R_MIPS_CALL16 glob2 0x0 +# CHECK-NEXT: 0x2 R_MIPS_LO16 loc1 0x0 +# CHECK-NEXT: } +# CHECK-NEXT: Section (3) .rela.text { +# CHECK-NEXT: 0x1 R_MIPS_32 glob1 0x1 +# CHECK-NEXT: 0x1 R_MIPS_CALL16 glob2 0x2 +# CHECK-NEXT: 0x2 R_MIPS_LO16 loc1 0x3 +# CHECK-NEXT: } +# CHECK-NEXT: ] |