[llvm] e6b55cb - [yaml2obj][obj2yaml] - Add lost test cases.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 04:40:50 PST 2020


Author: Georgii Rymar
Date: 2020-01-29T15:40:35+03:00
New Revision: e6b55cbcdc4c5a831c7d6e568506b0d7f6dee2a3

URL: https://github.com/llvm/llvm-project/commit/e6b55cbcdc4c5a831c7d6e568506b0d7f6dee2a3
DIFF: https://github.com/llvm/llvm-project/commit/e6b55cbcdc4c5a831c7d6e568506b0d7f6dee2a3.diff

LOG: [yaml2obj][obj2yaml] - Add lost test cases.

It is a part of https://reviews.llvm.org/D71872 which
was lost somehow during relanding after being reverted:

https://reviews.llvm.org/rG7570d387c21935b58afa67cb9ee17250e38721fa

Added: 
    llvm/test/tools/obj2yaml/relr-section.yaml
    llvm/test/tools/yaml2obj/ELF/relr-section.yaml

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/obj2yaml/relr-section.yaml b/llvm/test/tools/obj2yaml/relr-section.yaml
new file mode 100644
index 000000000000..42e7c44e0c0c
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/relr-section.yaml
@@ -0,0 +1,102 @@
+## Test how we dump SHT_RELR sections for 32 and 64-bit targets.
+
+## Test we use the "Entries" property when it is possible do
+## dump values correctly.
+
+# RUN: yaml2obj --docnum=1 %s -o %t.64le
+# RUN: obj2yaml %t.64le | FileCheck %s --check-prefix=ELF64LE
+# RUN: yaml2obj --docnum=2 %s -o %t.32le
+# RUN: obj2yaml %t.32le | FileCheck %s --check-prefix=ELF32LE
+# RUN: yaml2obj --docnum=3 %s -o %t.64be
+# RUN: obj2yaml %t.64be | FileCheck %s --check-prefix=ELF64BE
+# RUN: yaml2obj --docnum=4 %s -o %t.32be
+# RUN: obj2yaml %t.32be | FileCheck %s --check-prefix=ELF32BE
+
+# ELF64LE:      Sections:
+# ELF64LE-NEXT:   - Name:    .relr.dyn
+# ELF64LE-NEXT:     Type:    SHT_RELR
+# ELF64LE-NEXT:     EntSize: 0x0000000000000008
+# ELF64LE-NEXT:     Entries: [ 0x8877665544332211 ]
+
+# ELF32LE:      Sections:
+# ELF32LE-NEXT:   - Name:    .relr.dyn
+# ELF32LE-NEXT:     Type:    SHT_RELR
+# ELF32LE-NEXT:     EntSize: 0x0000000000000004
+# ELF32LE-NEXT:     Entries: [ 0x0000000044332211, 0x0000000088776655 ]
+
+# ELF64BE:      Sections:
+# ELF64BE-NEXT:   - Name:    .relr.dyn
+# ELF64BE-NEXT:     Type:    SHT_RELR
+# ELF64BE-NEXT:     EntSize: 0x0000000000000008
+# ELF64BE-NEXT:     Entries: [ 0x1122334455667788 ]
+
+# ELF32BE:      Sections:
+# ELF32BE-NEXT:  - Name:    .relr.dyn
+# ELF32BE-NEXT:    Type:    SHT_RELR
+# ELF32BE-NEXT:    EntSize: 0x0000000000000004
+# ELF32BE-NEXT:    Entries: [ 0x0000000011223344, 0x0000000055667788 ]
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name: .relr.dyn
+    Type: SHT_RELR
+    Content: "1122334455667788"
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name: .relr.dyn
+    Type: SHT_RELR
+    Content: "1122334455667788"
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2MSB
+  Type:    ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name: .relr.dyn
+    Type: SHT_RELR
+    Content: "1122334455667788"
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2MSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name: .relr.dyn
+    Type: SHT_RELR
+    Content: "1122334455667788"
+
+## Test we use the "Content" property when a SHT_RELR section is truncated.
+
+# RUN: yaml2obj --docnum=5 %s -o %t.content
+# RUN: obj2yaml %t.content | FileCheck %s --check-prefix=CONTENT
+
+# CONTENT:      - Name:    .relr.dyn
+# CONTENT-NEXT:   Type:    SHT_RELR
+# CONTENT-NEXT:   EntSize: 0x0000000000000008
+# CONTENT-NEXT:   Content: '11223344556677'
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2MSB
+  Type:    ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name: .relr.dyn
+    Type: SHT_RELR
+    Content: "11223344556677"

diff  --git a/llvm/test/tools/yaml2obj/ELF/relr-section.yaml b/llvm/test/tools/yaml2obj/ELF/relr-section.yaml
new file mode 100644
index 000000000000..8cd27c5d26ac
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/ELF/relr-section.yaml
@@ -0,0 +1,207 @@
+## Test how we create SHT_RELR sections.
+
+## Test that the content of SHT_RELR sections for 64-bit little endian targets is correct.
+# RUN: yaml2obj --docnum=1 %s -o %t.le64
+# RUN: llvm-readobj --sections --section-data %t.le64 | FileCheck %s --check-prefix=LE64
+
+# LE64:      Name: .relr.dyn
+# LE64-NEXT: Type: SHT_RELR
+# LE64-NEXT: Flags [
+# LE64-NEXT:   SHF_ALLOC
+# LE64-NEXT: ]
+# LE64-NEXT: Address: 0x0
+# LE64-NEXT: Offset: 0x40
+# LE64-NEXT: Size: 32
+# LE64-NEXT: Link: 0
+# LE64-NEXT: Info: 0
+# LE64-NEXT: AddressAlignment: 0
+# LE64-NEXT: EntrySize: 8
+# LE64-NEXT: SectionData (
+# LE64-NEXT:   0000: DDCCBBAA 00000000 2211FFEE 00000000
+# LE64-NEXT:   0010: 66554433 00000010 AA998877 00000010
+# LE64-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+## Set an arbitrary flag to demonstrate flags are set when requested.
+    Flags:   [ SHF_ALLOC ]
+    Entries: [ 0x00000000AABBCCDD, 0x00000000EEFF1122,
+               0x1000000033445566, 0x10000000778899AA ]
+
+## Test that the content of SHT_RELR sections for 64-bit big endian targets is correct.
+# RUN: yaml2obj --docnum=2 %s -o %t.be64
+# RUN: llvm-readobj --sections --section-data %t.be64 | FileCheck %s --check-prefix=BE64
+
+# BE64:      Name: .relr.dyn
+# BE64:      SectionData (
+# BE64-NEXT:   0000: 00000000 AABBCCDD 00000000 EEFF1122
+# BE64-NEXT:   0010: 10000000 33445566 10000000 778899AA
+# BE64-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2MSB
+  Type:    ET_DYN
+  Machine: EM_X86_64
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+## Set an arbitrary flag to demonstrate flags are set when requested.
+    Flags:   [ SHF_ALLOC ]
+    Entries: [ 0x00000000AABBCCDD, 0x00000000EEFF1122,
+               0x1000000033445566, 0x10000000778899AA ]
+
+## Test that the content of SHT_RELR sections for 32-bit little endian targets is correct.
+# RUN: yaml2obj --docnum=3 %s -o %t.le32
+# RUN: llvm-readobj --sections --section-data %t.le32 | FileCheck %s --check-prefix=LE32
+
+# LE32:      Name: .relr.dyn
+# LE32-NEXT: Type: SHT_RELR
+# LE32-NEXT: Flags [
+# LE32-NEXT:   SHF_ALLOC
+# LE32-NEXT: ]
+# LE32-NEXT: Address: 0x0
+# LE32-NEXT: Offset: 0x34
+# LE32-NEXT: Size: 16
+# LE32-NEXT: Link: 0
+# LE32-NEXT: Info: 0
+# LE32-NEXT: AddressAlignment: 0
+# LE32-NEXT: EntrySize: 4
+# LE32-NEXT: SectionData (
+# LE32-NEXT:   0000: DDCCBBAA BBAAFFEE BBAAFFEE BCAAFFEE
+# LE32-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+## Set an arbitrary flag to demonstrate flags are set when requested.
+    Flags:   [ SHF_ALLOC ]
+    Entries: [ 0xAABBCCDD, 0xEEFFAABB,
+               0xEEFFAABB, 0xEEFFAABC ]
+
+## Test that the content of SHT_RELR sections for 32-bit big endian targets is correct.
+# RUN: yaml2obj --docnum=4 %s -o %t.be32
+# RUN: llvm-readobj --sections --section-data %t.be32 | FileCheck %s --check-prefix=BE32
+
+# BE32:      Name: .relr.dyn
+# BE32:      SectionData (
+# BE32-NEXT:   0000: AABBCCDD EEFFAABB EEFFAABB EEFFAABC  |
+# BE32-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2MSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+## Set an arbitrary flag to demonstrate flags are set when requested.
+    Flags:   [ SHF_ALLOC ]
+    Entries: [ 0xAABBCCDD, 0xEEFFAABB,
+               0xEEFFAABB, 0xEEFFAABC ]
+
+## Test we can use "Content" to describe SHT_RELR section.
+# RUN: yaml2obj --docnum=5 %s -o %t.content
+# RUN: llvm-readobj --sections --section-data %t.content | FileCheck %s --check-prefix=CONTENT
+
+# CONTENT:      Name: .relr.dyn
+# CONTENT:      SectionData (
+# CONTENT-NEXT:   0000: 112233 |
+# CONTENT-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+    Content: "112233"
+
+## Check we are able to set an arbitrary sh_entsize.
+# RUN: yaml2obj --docnum=6 %s -o %t.entsize
+# RUN: llvm-readelf --sections %t.entsize | FileCheck %s --check-prefix=ENTSIZE
+
+# ENTSIZE: [Nr] Name      Type Address  Off    Size   ES
+# ENTSIZE: [ 1] .relr.dyn RELR 00000000 000034 000001 34
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+    EntSize: 0x34
+    Content: "12"
+
+## Test we can't use 64-bit offsets/bitmaps when creating a 32-bit object.
+# RUN: yaml2obj --docnum=7 %s -o %t.nottoolarge
+# RUN: llvm-readobj --sections --section-data %t.nottoolarge | FileCheck %s --check-prefix=NOT-TOO-LARGE
+
+# NOT-TOO-LARGE:      Name: .relr.dyn
+# NOT-TOO-LARGE:      SectionData (
+# NOT-TOO-LARGE-NEXT:   0000: FFFFFFFF
+# NOT-TOO-LARGE-NEXT: )
+
+# RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=TOO-LARGE
+# TOO-LARGE: error: .relr.dyn: the value is too large for 32-bits: 0x100000000
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+    Entries: [ 0x00000000FFFFFFFF ]
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+    Entries: [ 0x0000000100000000 ]
+
+## Test we can't specify "Entries" and "Content" properties at the same time.
+# RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=BOTH
+
+# BOTH: error: "Entries" and "Content" can't be used together
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:    ELFDATA2LSB
+  Type:    ET_DYN
+  Machine: EM_386
+Sections:
+  - Name:    .relr.dyn
+    Type:    SHT_RELR
+    Entries: [ 0x0 ]
+    Content: "00"


        


More information about the llvm-commits mailing list