diff --git a/llvm/test/Object/X86/yaml-elf-x86-rel-broken.yaml b/llvm/test/Object/X86/yaml-elf-x86-rel-broken.yaml deleted file mode 100644 --- a/llvm/test/Object/X86/yaml-elf-x86-rel-broken.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# RUN: yaml2obj %s -o %t -# RUN: obj2yaml %t | FileCheck %s - -# CHECK: Relocations: -# CHECK-NEXT: - Offset: -# CHECK-NEXT: Symbol: -# CHECK-NEXT: Type: 0x000000FF - -!ELF -FileHeader: - Class: ELFCLASS32 - Data: ELFDATA2LSB - Type: ET_REL - Machine: EM_386 -Sections: - - Type: SHT_PROGBITS - Name: .text - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - AddressAlign: 0x04 - Content: 0000000000000000 - - Type: SHT_REL - Name: .rel.text - Link: .symtab - Info: .text - AddressAlign: 0x04 - Relocations: - - Offset: 0 - Symbol: main - Type: 0xFF -Symbols: - - Name: main - Binding: STB_GLOBAL diff --git a/llvm/test/tools/obj2yaml/relocation-type.yaml b/llvm/test/tools/obj2yaml/relocation-type.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/obj2yaml/relocation-type.yaml @@ -0,0 +1,52 @@ +## Show how obj2yaml dumps relocation types. + +## Show that obj2yaml is able to dump relocation types when `e_machine` kind is unknown. +# RUN: yaml2obj %s -o %t1 -DMACHINE=0x1234 +# RUN: obj2yaml %t1 | FileCheck %s -DMACHINE=0x1234 -DFIRST=0x00000000 -DSECOND=0x00000001 + +# CHECK: --- !ELF +# CHECK-NEXT: FileHeader: +# CHECK-NEXT: Class: ELFCLASS64 +# CHECK-NEXT: Data: ELFDATA2MSB +# CHECK-NEXT: Type: ET_REL +# CHECK-NEXT: Machine: [[MACHINE]] +# CHECK-NEXT: Sections: +# CHECK-NEXT: - Name: .rela.text +# CHECK-NEXT: Type: SHT_RELA +# CHECK-NEXT: EntSize: 0x0000000000000018 +# CHECK-NEXT: Relocations: +# CHECK-NEXT: - Offset: 0x0000000000000009 +# CHECK-NEXT: Type: [[FIRST]] +# CHECK-NEXT: - Offset: 0x0000000000000008 +# CHECK-NEXT: Type: [[SECOND]] +# CHECK-NEXT: - Offset: 0x0000000000000007 +# CHECK-NEXT: Type: 0x0000007F +# CHECK-NEXT: - Offset: 0x0000000000000006 +# CHECK-NEXT: Type: 0x000000FF +# CHECK-NEXT: ... + +## Show how obj2yaml dumps relocation types when `e_machine` kind is known. +## In this case unknown relocation types are dumped as hex values. +## All known relocation types are printed as strings representing relocation names. +# RUN: yaml2obj %s -o %t2 -DMACHINE=EM_X86_64 +# RUN: obj2yaml %t2 | FileCheck %s -DMACHINE=EM_X86_64 -DFIRST=R_X86_64_NONE -DSECOND=R_X86_64_64 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2MSB + Type: ET_REL + Machine: [[MACHINE]] +Sections: + - Name: .rela.text + Type: SHT_RELA + Relocations: +## Test a few noticeable possible values: 0, 1, max(int8_t)=127, max(uint8_t)=0xFF=-1 + - Offset: 0x9 + Type: 0x0 + - Offset: 0x8 + Type: 0x1 + - Offset: 0x7 + Type: 0x7F + - Offset: 0x6 + Type: 0xFF diff --git a/llvm/test/tools/obj2yaml/relocation-unsupported-machine.yaml b/llvm/test/tools/obj2yaml/relocation-unsupported-machine.yaml deleted file mode 100644 --- a/llvm/test/tools/obj2yaml/relocation-unsupported-machine.yaml +++ /dev/null @@ -1,35 +0,0 @@ -## Show that obj2yaml is able to dump relocations when `e_machine` is unknown. - -# RUN: yaml2obj %s -o %t1 -# RUN: obj2yaml %t1 | FileCheck %s - -# CHECK: --- !ELF -# CHECK-NEXT: FileHeader: -# CHECK-NEXT: Class: ELFCLASS64 -# CHECK-NEXT: Data: ELFDATA2MSB -# CHECK-NEXT: Type: ET_REL -# CHECK-NEXT: Machine: 0x1234 -# CHECK-NEXT: Sections: -# CHECK-NEXT: - Name: .rela.text -# CHECK-NEXT: Type: SHT_RELA -# CHECK-NEXT: EntSize: 0x0000000000000018 -# CHECK-NEXT: Relocations: -# CHECK-NEXT: - Offset: 0x0000000000000001 -# CHECK-NEXT: Type: 0x00000002 -# CHECK-NEXT: - Offset: 0x0000000000000003 -# CHECK-NEXT: Type: 0x00000004 - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2MSB - Type: ET_REL - Machine: 0x1234 -Sections: - - Name: .rela.text - Type: SHT_RELA - Relocations: - - Offset: 0x1 - Type: 0x2 - - Offset: 0x3 - Type: 0x4 diff --git a/llvm/test/tools/yaml2obj/ELF/relocation-type.yaml b/llvm/test/tools/yaml2obj/ELF/relocation-type.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/yaml2obj/ELF/relocation-type.yaml @@ -0,0 +1,36 @@ +## Here we test that an arbitrary hex value can be used for a relocation type. + +## Show that yaml2obj is able to produce relocations for an unknown e_machine kind properly. +# RUN: yaml2obj %s -o %t1 -DMACHINE=0x1234 +# RUN: llvm-readelf %t1 --relocations | FileCheck %s -DFIRST=Unknown -DSECOND=Unknown + +# CHECK: Relocation section '.rela.text' at offset 0x40 contains 4 entries: +# CHECK: Offset Info Type +# CHECK-NEXT: 0000000000000009 0000000000000000 [[FIRST]] 0 +# CHECK-NEXT: 0000000000000008 0000000000000001 [[SECOND]] 0 +# CHECK-NEXT: 0000000000000007 000000000000007f Unknown 0 +# CHECK-NEXT: 0000000000000006 00000000000000ff Unknown 0 + +## Show that yaml2obj is able to produce relocations for an arbitrary known e_machine kind properly. +# RUN: yaml2obj %s -o %t2 -DMACHINE=EM_X86_64 +# RUN: llvm-readelf %t2 --relocations | FileCheck %s -DFIRST=R_X86_64_NONE -DSECOND=R_X86_64_64 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2MSB + Type: ET_REL + Machine: [[MACHINE]] +Sections: + - Name: .rela.text + Type: SHT_RELA + Relocations: +## Test a few noticeable possible values: 0, 1, max(int8_t)=127, max(uint8_t)=0xFF=-1 + - Offset: 0x9 + Type: 0x0 + - Offset: 0x8 + Type: 0x1 + - Offset: 0x7 + Type: 0x7F + - Offset: 0x6 + Type: 0xFF diff --git a/llvm/test/tools/yaml2obj/ELF/relocation-unsupported-machine.yaml b/llvm/test/tools/yaml2obj/ELF/relocation-unsupported-machine.yaml deleted file mode 100644 --- a/llvm/test/tools/yaml2obj/ELF/relocation-unsupported-machine.yaml +++ /dev/null @@ -1,24 +0,0 @@ -## Show that yaml2obj is able to write relocations for an unknown e_machine properly. - -# RUN: yaml2obj %s -o %t1 -# RUN: llvm-readelf %t1 --relocations | FileCheck %s - -# CHECK: Relocation section '.rela.text' at offset 0x40 contains 2 entries: -# CHECK: Offset Info Type Symbol's Value Symbol's Name + Addend -# CHECK-NEXT: 0000000000000001 0000000000000002 Unknown 0 -# CHECK-NEXT: 0000000000000003 0000000000000004 Unknown 0 - ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2MSB - Type: ET_REL - Machine: 0x1234 -Sections: - - Name: .rela.text - Type: SHT_RELA - Relocations: - - Offset: 0x1 - Type: 0x2 - - Offset: 0x3 - Type: 0x4