[PATCH] D59763: [llvm-objcopy] - Strip sections before symbols.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 06:52:15 PDT 2019


grimar updated this revision to Diff 192096.
grimar marked 2 inline comments as done.
grimar added a comment.

- Addressed review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59763/new/

https://reviews.llvm.org/D59763

Files:
  test/tools/llvm-objcopy/ELF/strip-all-relocations.test
  tools/llvm-objcopy/ELF/ELFObjcopy.cpp


Index: tools/llvm-objcopy/ELF/ELFObjcopy.cpp
===================================================================
--- tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -542,10 +542,10 @@
     Obj.OSABI = Config.OutputArch.getValue().OSABI;
   }
 
-  if (Error E = updateAndRemoveSymbols(Config, Obj))
+  if (Error E = replaceAndRemoveSections(Config, Obj))
     return E;
 
-  if (Error E = replaceAndRemoveSections(Config, Obj))
+  if (Error E = updateAndRemoveSymbols(Config, Obj))
     return E;
 
   if (!Config.SectionsToRename.empty()) {
Index: test/tools/llvm-objcopy/ELF/strip-all-relocations.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objcopy/ELF/strip-all-relocations.test
@@ -0,0 +1,42 @@
+# RUN: yaml2obj %s > %t
+
+## Check we are able to strip all symbols and relocatable information at the same time.
+
+# RUN: llvm-objcopy -S %t %t2
+# RUN: llvm-objdump --section-headers %t2 | FileCheck %s
+
+# RUN: llvm-objcopy --strip-all-gnu %t %t2
+# RUN: llvm-objdump --section-headers %t2 | FileCheck %s
+
+## Check we are able to strip the particular symbol if we
+## strip the corresponding relocation section at the same time.
+
+# RUN: llvm-objcopy --strip-symbol=bar -R .rela.text %t2
+# RUN: llvm-objdump --section-headers %t2 | FileCheck %s
+
+# CHECK-NOT: .symtab
+# CHECK-NOT: .rela.text
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] 
+    Content:         00000000
+  - Name:            .rela.text
+    Type:            SHT_RELA
+    Link:            .symtab
+    Info:            .text
+    Relocations:
+      - Offset:          0x0000000000000000
+        Symbol:          bar
+        Type:            R_X86_64_32S
+Symbols:
+  Global:
+    - Name:     bar
+      Section:  .text


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59763.192096.patch
Type: text/x-patch
Size: 2021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190325/535e5cba/attachment.bin>


More information about the llvm-commits mailing list