]> granicus.if.org Git - llvm/commitdiff
[yaml2obj] - Check we correctly set the sh_info field of .symtab section.
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 4 Apr 2019 11:49:54 +0000 (11:49 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 4 Apr 2019 11:49:54 +0000 (11:49 +0000)
initSymtabSectionHeader has the following line:
SHeader.sh_info = findLocalsNum(Symbols) + 1;

As was mentioned in a review comments for D60122,
it is never tested. The patch adds a test.

Differential revision: https://reviews.llvm.org/D60192

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357687 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/yaml2obj/local-symbols.yaml [new file with mode: 0644]

diff --git a/test/tools/yaml2obj/local-symbols.yaml b/test/tools/yaml2obj/local-symbols.yaml
new file mode 100644 (file)
index 0000000..8cd5b01
--- /dev/null
@@ -0,0 +1,36 @@
+# Check we correctly set the sh_info field of .symtab section.
+# A symbol table section's sh_info section header member holds
+# the symbol table index for the first non-local symbol.
+
+# RUN: yaml2obj -docnum=1 %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=ONE
+# ONE: Name: .symtab
+# ONE: Info: 2
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_X86_64
+Symbols:
+  - Name: local
+  - Name: global
+    Binding: STB_GLOBAL
+
+# RUN: yaml2obj -docnum=2 %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s --check-prefix=TWO
+# TWO: Name: .symtab
+# TWO: Info: 3
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_X86_64
+Symbols:
+  - Name:    local1
+  - Name:    local2
+  - Name:    global
+    Binding: STB_GLOBAL