[PATCH] D59763: [llvm-objcopy] - Strip sections before symbols.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 05:16:51 PDT 2019
grimar created this revision.
grimar added reviewers: jhenderson, jakehehrlich, rupprecht.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
grimar retitled this revision from "[llvm-objcopy] - Strip sections before symbols," to "[llvm-objcopy] - Strip sections before symbols.".
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=40007.
It is rebased on top of D59762 <https://reviews.llvm.org/D59762>.
Idea is to swap the order of stripping. So that we strip sections before
symbols what allows us to strip relocation sections without emitting
the error about relative symbols.
https://reviews.llvm.org/D59763
Files:
test/tools/llvm-objcopy/ELF/strip-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-relocations.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objcopy/ELF/strip-relocations.test
@@ -0,0 +1,35 @@
+# RUN: yaml2obj %s > %t
+
+## Check we are able to strip all symbols and relocatable information.
+
+# 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-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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59763.192081.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190325/e8dbdc97/attachment-0001.bin>
More information about the llvm-commits
mailing list