[PATCH] D63641: [llvm-objcopy] - Get rid of dynrel.elf precompiled binary from inputs.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 03:45:07 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, jakehehrlich, alexshap, MaskRay, rupprecht.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

We do not have to spread using the precompiled binaries in the test,
when we can use YAML. This patch removes the dynrel.elf binary and adds
a few comments to the test cases.


https://reviews.llvm.org/D63641

Files:
  test/tools/llvm-objcopy/ELF/Inputs/dynrel.elf
  test/tools/llvm-objcopy/ELF/dynamic-relocations.test
  test/tools/llvm-objcopy/ELF/prefix-alloc-sections-dynrelocsec.test


Index: test/tools/llvm-objcopy/ELF/prefix-alloc-sections-dynrelocsec.test
===================================================================
--- test/tools/llvm-objcopy/ELF/prefix-alloc-sections-dynrelocsec.test
+++ test/tools/llvm-objcopy/ELF/prefix-alloc-sections-dynrelocsec.test
@@ -1,5 +1,24 @@
-# RUN: llvm-objcopy --prefix-alloc-sections=.prefix %p/Inputs/dynrel.elf %t
-# RUN: llvm-readobj --sections %t | FileCheck %s
+## Check that llvm-objcopy can correctly add a prefix for
+## dynamic relocation section and its target section.
+
+# RUN: yaml2obj %s > %t1
+# RUN: llvm-objcopy --prefix-alloc-sections=.prefix %t1 %t2
+# RUN: llvm-readobj --sections %t2 | FileCheck %s
 
 # CHECK: Name: .prefix.rela.plt
 # CHECK: Name: .prefix.plt
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_EXEC
+  Machine: EM_X86_64
+Sections:
+  - Name:  .rela.plt
+    Type:  SHT_RELA
+    Flags: [ SHF_ALLOC ]
+    Link:  0
+  - Name:  .plt
+    Type:  SHT_PROGBITS
+    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Index: test/tools/llvm-objcopy/ELF/dynamic-relocations.test
===================================================================
--- test/tools/llvm-objcopy/ELF/dynamic-relocations.test
+++ test/tools/llvm-objcopy/ELF/dynamic-relocations.test
@@ -1,19 +1,44 @@
-# RUN: llvm-objcopy %p/Inputs/dynrel.elf %t
-# RUN: llvm-readobj --sections --section-data %t | FileCheck %s
+## Check that llvm-objcopy can handle an object
+## containing dynamic relocations properly.
 
-#CHECK:         Name: .rela.plt
-#CHECK-NEXT:    Type: SHT_RELA
-#CHECK-NEXT:    Flags [
-#CHECK-NEXT:      SHF_ALLOC
-#CHECK-NEXT:    ]
-#CHECK-NEXT:    Address:
-#CHECK-NEXT:    Offset:
-#CHECK-NEXT:    Size: 24
-#CHECK-NEXT:    Link:
-#CHECK-NEXT:    Info:
-#CHECK-NEXT:    AddressAlignment: 8
-#CHECK-NEXT:    EntrySize: 24
-#CHECK-NEXT:    SectionData (
-#CHECK-NEXT:       0000: 18202000 00000000 07000000 01000000  |.  .............|
-#CHECK-NEXT:       0010: 00000000 00000000                    |........|
-#CHECK-NEXT:    )
+# RUN: yaml2obj %s > %t1
+# RUN: llvm-objcopy %t1 %t2
+# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s
+
+# CHECK:         Name: .rela.plt
+# CHECK-NEXT:    Type: SHT_RELA
+# CHECK-NEXT:    Flags [
+# CHECK-NEXT:      SHF_ALLOC
+# CHECK-NEXT:    ]
+# CHECK-NEXT:    Address:
+# CHECK-NEXT:    Offset:
+# CHECK-NEXT:    Size: 24
+# CHECK-NEXT:    Link:
+# CHECK-NEXT:    Info:
+# CHECK-NEXT:    AddressAlignment: 8
+# CHECK-NEXT:    EntrySize: 24
+# CHECK-NEXT:    SectionData (
+# CHECK-NEXT:       0000: 18202000 00000000 07000000 01000000  |.  .............|
+# CHECK-NEXT:       0010: 00000000 00000000                    |........|
+# CHECK-NEXT:    )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_EXEC
+  Machine: EM_X86_64
+Sections:
+  - Name:         .rela.plt
+    Type:         SHT_RELA
+    Flags:        [ SHF_ALLOC ]
+    Address:      0x0000000000200220
+    Link:         0
+    AddressAlign: 0x0000000000000008
+    Relocations:
+      - Offset: 0x0000000000202018
+        Symbol: foo
+        Type:   R_X86_64_JUMP_SLOT
+Symbols:
+  - Name:    foo
+    Binding: STB_GLOBAL


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63641.205960.patch
Type: text/x-patch
Size: 3187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190621/d8c85119/attachment.bin>


More information about the llvm-commits mailing list