[llvm] 73d9646 - [llvm-readelf/obj][test] - Stop using precompiled binary in mips-plt.test

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 01:50:08 PDT 2020


Author: Georgii Rymar
Date: 2020-10-09T11:48:49+03:00
New Revision: 73d964646c91975cd2fae00ccf9ce5d3c3c0ba40

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

LOG: [llvm-readelf/obj][test] - Stop using precompiled binary in mips-plt.test

This removes the precompiled binary and rewrites test to use YAML.

After this change we'll have no more precompiled inputs in `llvm-readobj/ELF/Inputs`.

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

Added: 
    

Modified: 
    llvm/test/tools/llvm-readobj/ELF/mips-plt.test

Removed: 
    llvm/test/tools/llvm-readobj/ELF/Inputs/got-plt.exe.elf-mipsel


################################################################################
diff  --git a/llvm/test/tools/llvm-readobj/ELF/Inputs/got-plt.exe.elf-mipsel b/llvm/test/tools/llvm-readobj/ELF/Inputs/got-plt.exe.elf-mipsel
deleted file mode 100644
index 8cdc69ffa562..000000000000
Binary files a/llvm/test/tools/llvm-readobj/ELF/Inputs/got-plt.exe.elf-mipsel and /dev/null 
diff er

diff  --git a/llvm/test/tools/llvm-readobj/ELF/mips-plt.test b/llvm/test/tools/llvm-readobj/ELF/mips-plt.test
index 3dfe46c4b786..3f57a39988e8 100644
--- a/llvm/test/tools/llvm-readobj/ELF/mips-plt.test
+++ b/llvm/test/tools/llvm-readobj/ELF/mips-plt.test
@@ -1,76 +1,99 @@
-# RUN: llvm-readobj -A %p/Inputs/got-plt.exe.elf-mipsel | FileCheck %s
-# RUN: llvm-readelf -A %p/Inputs/got-plt.exe.elf-mipsel | FileCheck --check-prefix=GNU %s
-
-# CHECK:      PLT GOT {
-# CHECK-NEXT:   Reserved entries [
-# CHECK-NEXT:     Entry {
-# CHECK-NEXT:       Address: 0x410814
-# CHECK-NEXT:       Initial: 0x0
-# CHECK-NEXT:       Purpose: PLT lazy resolver
-# CHECK-NEXT:     }
-# CHECK-NEXT:     Entry {
-# CHECK-NEXT:       Address: 0x410818
-# CHECK-NEXT:       Initial: 0x0
-# CHECK-NEXT:       Purpose: Module pointer
-# CHECK-NEXT:     }
-# CHECK-NEXT:   ]
-# CHECK-NEXT:   Entries [
-# CHECK-NEXT:     Entry {
-# CHECK-NEXT:       Address: 0x41081C
-# CHECK-NEXT:       Initial: 0x4007C0
-# CHECK-NEXT:       Value: 0x0
-# CHECK-NEXT:       Type: Function (0x2)
-# CHECK-NEXT:       Section: Undefined (0x0)
-# CHECK-NEXT:       Name: puts at GLIBC_2.0 (71)
-# CHECK-NEXT:     }
-# CHECK-NEXT:     Entry {
-# CHECK-NEXT:       Address: 0x410820
-# CHECK-NEXT:       Initial: 0x4007C0
-# CHECK-NEXT:       Value: 0x0
-# CHECK-NEXT:       Type: Function (0x2)
-# CHECK-NEXT:       Section: Undefined (0x0)
-# CHECK-NEXT:       Name: __libc_start_main at GLIBC_2.0 (53)
-# CHECK-NEXT:     }
-# CHECK-NEXT:   ]
-# CHECK-NEXT: }
-
-# GNU:      Primary GOT:
-# GNU-NEXT:  Canonical gp value: 00418840
-
-# GNU:       Reserved entries:
-# GNU-NEXT:    Address     Access  Initial Purpose
-# GNU-NEXT:   00410850 -32752(gp) 00000000 Lazy resolver
-# GNU-NEXT:   00410854 -32748(gp) 80000000 Module pointer (GNU extension)
-
-# GNU:       Local entries:
-# GNU-NEXT:    Address     Access  Initial
-# GNU-NEXT:   00410858 -32744(gp) 004003d4
-# GNU-NEXT:   0041085c -32740(gp) 00410800
-# GNU-NEXT:   00410860 -32736(gp) 00000000
-
-# GNU:       Global entries:
-# GNU-NEXT:    Address     Access  Initial Sym.Val. Type    Ndx Name
-# GNU-NEXT:   00410864 -32732(gp) 00000000 00000000 FUNC    UND __gmon_start__
-# GNU-NEXT: PLT GOT:
-
-# GNU:       Reserved entries:
-# GNU-NEXT:    Address  Initial Purpose
-# GNU-NEXT:   00410814 00000000 PLT lazy resolver
-# GNU-NEXT:   00410818 00000000 Module pointer
-
-# GNU:       Entries:
-# GNU-NEXT:    Address  Initial Sym.Val. Type    Ndx Name
-# GNU-NEXT:   0041081c 004007c0 00000000 FUNC    UND puts
-# GNU-NEXT:   00410820 004007c0 00000000 FUNC    UND __libc_start_main
+## Check that we are able to dump MIPS PLT GOT entries using -A properly.
+
+# RUN: yaml2obj --docnum=1 %s -o %t.plt.o
+# RUN: llvm-readobj -A %t.plt.o | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf -A %t.plt.o | \
+# RUN:   FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU
+
+# LLVM:      PLT GOT {
+# LLVM-NEXT:   Reserved entries [
+# LLVM-NEXT:     Entry {
+# LLVM-NEXT:       Address: 0x2000
+# LLVM-NEXT:       Initial: 0x0
+# LLVM-NEXT:       Purpose: PLT lazy resolver
+# LLVM-NEXT:     }
+# LLVM-NEXT:     Entry {
+# LLVM-NEXT:       Address: 0x2008
+# LLVM-NEXT:       Initial: 0x0
+# LLVM-NEXT:       Purpose: Module pointer
+# LLVM-NEXT:     }
+# LLVM-NEXT:   ]
+# LLVM-NEXT:   Entries [
+# LLVM-NEXT:     Entry {
+# LLVM-NEXT:       Address: 0x2010
+# LLVM-NEXT:       Initial: 0x0
+# LLVM-NEXT:       Value: 0x0
+# LLVM-NEXT:       Type: None (0x0)
+# LLVM-NEXT:       Section: Undefined (0x0)
+# LLVM-NEXT:       Name: foo (5)
+# LLVM-NEXT:     }
+# LLVM-NEXT:     Entry {
+# LLVM-NEXT:       Address: 0x2018
+# LLVM-NEXT:       Initial: 0x0
+# LLVM-NEXT:       Value: 0x0
+# LLVM-NEXT:       Type: None (0x0)
+# LLVM-NEXT:       Section: Undefined (0x0)
+# LLVM-NEXT:       Name: bar (1)
+# LLVM-NEXT:     }
+# LLVM-NEXT:   ]
+# LLVM-NEXT: }
+
+#       GNU:PLT GOT:
+# GNU-EMPTY:
+#  GNU-NEXT: Reserved entries:
+#  GNU-NEXT:   Address  Initial Purpose
+#  GNU-NEXT:  0000000000002000 0000000000000000 PLT lazy resolver
+#  GNU-NEXT:  0000000000002008 0000000000000000 Module pointer
+# GNU-EMPTY:
+#  GNU-NEXT: Entries:
+#  GNU-NEXT:   Address  Initial Sym.Val. Type    Ndx Name
+#  GNU-NEXT:  0000000000002010 0000000000000000 0000000000000000 NOTYPE  UND foo
+#  GNU-NEXT:  0000000000002018 0000000000000000 0000000000000000 NOTYPE  UND bar
+#   GNU-NOT:{{.}}
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_MIPS
+Sections:
+  - Name:    .rel.plt
+    Type:    SHT_REL
+    Flags:   [ SHF_ALLOC ]
+    Address: 0x1000
+    Link:    .dynsym
+    Relocations:
+      - Offset: 0x1
+        Symbol: 1
+        Type:   R_MIPS_JUMP_SLOT
+      - Offset: 0x2
+        Symbol: 2
+        Type:   R_MIPS_JUMP_SLOT
+  - Name:    .got.plt
+    Type:    SHT_PROGBITS
+    Flags:   [ SHF_WRITE, SHF_ALLOC ]
+    Address: 0x2000
+    Size:    32 ## (dynamic symbols number + 2) * 8
+  - Name: .dynamic
+    Type: SHT_DYNAMIC
+    Entries:
+      - Tag:   DT_JMPREL
+        Value: 0x1000
+      - Tag:   DT_MIPS_PLTGOT
+        Value: 0x2000
+DynamicSymbols:
+  - Name:   "foo"
+  - Name:   "bar"
 
 ## Check we report errors when dynamic tags, needed for dumping PLT, are missing.
 
-# RUN: yaml2obj --docnum=1 -DTAG=DT_MIPS_PLTGOT %s -o %t.err1.o
+# RUN: yaml2obj --docnum=2 -DTAG=DT_MIPS_PLTGOT %s -o %t.err1.o
 # RUN: not llvm-readobj -A %t.err1.o 2>&1 | FileCheck %s -DFILE=%t.err1.o --check-prefix=ERR1
 
 # ERR1: error: '[[FILE]]': cannot find JMPREL dynamic tag
 
-# RUN: yaml2obj --docnum=1 -DTAG=DT_JMPREL %s -o %t.err2.o
+# RUN: yaml2obj --docnum=2 -DTAG=DT_JMPREL %s -o %t.err2.o
 # RUN: not llvm-readobj -A %t.err2.o 2>&1 | FileCheck %s -DFILE=%t.err2.o --check-prefix=ERR2
 
 # ERR2: error: '[[FILE]]': cannot find MIPS_PLTGOT dynamic tag
@@ -91,12 +114,12 @@ Sections:
         Value: 0
 
 ## Check we report errors when we are unable to find PLTGOT/JMPREL sections.
-# RUN: yaml2obj --docnum=2 %s -DVAL1=0xffff -o %t.err3.o
+# RUN: yaml2obj --docnum=3 %s -DVAL1=0xffff -o %t.err3.o
 # RUN: not llvm-readobj -A %t.err3.o 2>&1 | FileCheck %s -DFILE=%t.err3.o -check-prefix ERR3
 
 # ERR3: error: '[[FILE]]': there is no non-empty PLTGOT section at 0xffff
 
-# RUN: yaml2obj --docnum=2 %s -DVAL2=0xffff -o %t.err4.o
+# RUN: yaml2obj --docnum=3 %s -DVAL2=0xffff -o %t.err4.o
 # RUN: not llvm-readobj -A %t.err4.o 2>&1 | FileCheck %s -DFILE=%t.err4.o -check-prefix ERR4
 
 # ERR4: error: '[[FILE]]': there is no non-empty RELPLT section at 0xffff
@@ -126,23 +149,23 @@ DynamicSymbols: []
 
 ## Check we report errors when we are unable to dump PLTGOT properly.
 
-# RUN: yaml2obj --docnum=2 -DVAL1=0x100 %s -o %t.err5.o
+# RUN: yaml2obj --docnum=3 -DVAL1=0x100 %s -o %t.err5.o
 # RUN: not llvm-readobj -A %t.err5.o 2>&1 | FileCheck %s -DFILE=%t.err5.o -check-prefix ERR5
 
 # ERR5: error: '[[FILE]]': unable to read PLTGOT section content: section [index 2] has a sh_offset (0x70) + sh_size (0xffffffff) that is greater than the file size (0x280)
 
-# RUN: yaml2obj --docnum=2 -DVAL2=0x100 -DLINK=0xaaaaaaaa %s -o %t.err6.o
+# RUN: yaml2obj --docnum=3 -DVAL2=0x100 -DLINK=0xaaaaaaaa %s -o %t.err6.o
 # RUN: not llvm-readobj -A %t.err6.o 2>&1 | FileCheck %s -DFILE=%t.err6.o -check-prefix ERR6
 
 # ERR6: error: '[[FILE]]': unable to get a symbol table linked to the SHT_PROGBITS section with index 2: invalid section index: 2863311530
 
-# RUN: yaml2obj --docnum=2 -DVAL2=0x100 %s -o %t.err7.o
+# RUN: yaml2obj --docnum=3 -DVAL2=0x100 %s -o %t.err7.o
 # RUN: not llvm-readobj -A %t.err7.o 2>&1 | FileCheck %s -DFILE=%t.err7.o -check-prefix ERR7
 
 # ERR7: error: '[[FILE]]': unable to get a string table for the SHT_DYNAMIC section with index 1: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
 
 ## Check how we print PLT entries when they are unnamed section symbols.
-# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: yaml2obj --docnum=4 %s -o %t3
 # RUN: llvm-readobj -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-LLVM
 # RUN: llvm-readelf -A %t3 2>&1 | FileCheck %s -DFILE=%t3 --check-prefix=SEC-SYMS-GNU
 


        


More information about the llvm-commits mailing list