summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorGeorgii Rymar <grimar@accesssoftek.com>2019-11-22 17:18:34 +0300
committerGeorgii Rymar <grimar@accesssoftek.com>2019-11-25 12:57:53 +0300
commit9659464d7e7f30c6a1cee07c739dfe8f812924fd (patch)
tree1a066995b2f806e663c465c3608740f5c02ae296 /llvm/test
parente841029aef74d99d1cb9443edd4a7b761d84ff45 (diff)
downloadbcm5719-llvm-9659464d7e7f30c6a1cee07c739dfe8f812924fd.tar.gz
bcm5719-llvm-9659464d7e7f30c6a1cee07c739dfe8f812924fd.zip
[yaml2obj/obj2yaml] - Add support for SHT_LLVM_DEPENDENT_LIBRARIES sections.
This section contains strings specifying libraries to be added to the link by the linker. The strings are encoded as standard null-terminated UTF-8 strings. This patch adds a way to describe and dump SHT_LLVM_DEPENDENT_LIBRARIES sections. I introduced a new YAMLFlowString type here. That used to teach obj2yaml to dump them like: ``` Libraries: [ foo, bar ] ``` instead of the following (if StringRef would be used): ``` Libraries: - foo - bar ``` Differential revision: https://reviews.llvm.org/D70598
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/tools/obj2yaml/llvm-deplibs-section.yaml42
-rw-r--r--llvm/test/tools/yaml2obj/ELF/llvm-deplibs-section.yaml87
2 files changed, 129 insertions, 0 deletions
diff --git a/llvm/test/tools/obj2yaml/llvm-deplibs-section.yaml b/llvm/test/tools/obj2yaml/llvm-deplibs-section.yaml
new file mode 100644
index 00000000000..d2cd6e706c3
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/llvm-deplibs-section.yaml
@@ -0,0 +1,42 @@
+## Check how obj2yaml produces SHT_LLVM_DEPENDENT_LIBRARIES section descriptions.
+
+# RUN: yaml2obj %s -o %t
+# RUN: obj2yaml %t | FileCheck %s
+
+# CHECK: Sections:
+# CHECK-NEXT: - Name: .deplibs.single
+# CHECK-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES
+# CHECK-NEXT: Libraries: [ foo ]
+# CHECK-NEXT: - Name: .deplibs.multiple
+# CHECK-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES
+# CHECK-NEXT: Libraries: [ foo, bar, foo ]
+# CHECK-NEXT: - Name: .deplibs.empty
+# CHECK-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES
+# CHECK-NEXT: Libraries: [ ]
+# CHECK-NEXT: - Name: .deplibs.nonul
+# CHECK-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES
+# CHECK-NEXT: Content: 666F6F
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+## Case 1: test we use "Libraries" when dumping a valid section with a null-terminated string.
+ - Name: .deplibs.single
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Libraries: [ foo ]
+## Case 2: the same, but the section has multiple strings.
+ - Name: .deplibs.multiple
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Libraries: [ foo, bar, foo ]
+## Case 3: test we use "Libraries" when dumping an empty section.
+ - Name: .deplibs.empty
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Libraries: [ ]
+## Case 4: test we use "Content" when dumping a non-null terminated section.
+ - Name: .deplibs.nonul
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Content: "666f6f"
diff --git a/llvm/test/tools/yaml2obj/ELF/llvm-deplibs-section.yaml b/llvm/test/tools/yaml2obj/ELF/llvm-deplibs-section.yaml
new file mode 100644
index 00000000000..0ef19929e80
--- /dev/null
+++ b/llvm/test/tools/yaml2obj/ELF/llvm-deplibs-section.yaml
@@ -0,0 +1,87 @@
+## Check how yaml2obj produces SHT_LLVM_DEPENDENT_LIBRARIES sections.
+
+## Check we can describe SHT_LLVM_DEPENDENT_LIBRARIES using
+## "Libraries" and "Content" properies.
+
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=LIBRARIES
+
+# LIBRARIES: Name: .deplibs.lib
+# LIBRARIES-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES (0x6FFF4C04)
+# LIBRARIES-NEXT: Flags [ (0x0)
+# LIBRARIES-NEXT: ]
+# LIBRARIES-NEXT: Address: 0x0
+# LIBRARIES-NEXT: Offset: 0x40
+# LIBRARIES-NEXT: Size: 12
+# LIBRARIES-NEXT: Link: 0
+# LIBRARIES-NEXT: Info: 0
+# LIBRARIES-NEXT: AddressAlignment: 0
+# LIBRARIES-NEXT: EntrySize: 0
+# LIBRARIES-NEXT: SectionData (
+# LIBRARIES-NEXT: 0000: 666F6F00 62617200 666F6F00 |foo.bar.foo.|
+# LIBRARIES-NEXT: )
+
+# LIBRARIES: Name: .deplibs.content
+# LIBRARIES-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES
+# LIBRARIES-NEXT: Flags [
+# LIBRARIES-NEXT: ]
+# LIBRARIES-NEXT: Address: 0x0
+# LIBRARIES-NEXT: Offset: 0x4C
+# LIBRARIES-NEXT: Size: 3
+# LIBRARIES-NEXT: Link: 0
+# LIBRARIES-NEXT: Info: 0
+# LIBRARIES-NEXT: AddressAlignment: 0
+# LIBRARIES-NEXT: EntrySize: 0
+# LIBRARIES-NEXT: SectionData (
+# LIBRARIES-NEXT: 0000: 112233
+# LIBRARIES-NEXT: )
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .deplibs.lib
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Libraries: [ foo, bar, foo ]
+ - Name: .deplibs.content
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Content: "112233"
+
+## Check we report an error when "Libraries" and "Content" are used together.
+
+# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=LIBS-CONTENT
+
+# LIBS-CONTENT: error: SHT_LLVM_DEPENDENT_LIBRARIES: "Libraries" and "Content" can't be used together
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .deplibs
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
+ Content: "FF"
+ Libraries: [ foo ]
+
+## Check we create an empty section when neither "Libraries" nor "Content" are specified.
+
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: llvm-readelf --sections %t3 | FileCheck %s --check-prefix=NOPROPS
+
+# NOPROPS: [Nr] Name Type Address Off Size
+# NOPROPS: [ 1] .deplibs LLVM_DEPENDENT_LIBRARIES 0000000000000000 000040 000000
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .deplibs
+ Type: SHT_LLVM_DEPENDENT_LIBRARIES
OpenPOWER on IntegriCloud