[PATCH] D61641: [llvm-objcopy] Strip file symbols with --strip-unneeded
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 07:39:04 PDT 2019
evgeny777 created this revision.
evgeny777 added reviewers: jakehehrlich, rupprecht, jhenderson.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
I don't get why such symbols are kept. Also it's always possible to use --keep-file-symbols if they shouldn't be stripped for whatever reason
https://reviews.llvm.org/D61641
Files:
test/tools/llvm-objcopy/ELF/strip-unneeded.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
@@ -324,7 +324,7 @@
static bool isUnneededSymbol(const Symbol &Sym) {
return !Sym.Referenced &&
(Sym.Binding == STB_LOCAL || Sym.getShndx() == SHN_UNDEF) &&
- Sym.Type != STT_FILE && Sym.Type != STT_SECTION;
+ Sym.Type != STT_SECTION;
}
static Error updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) {
Index: test/tools/llvm-objcopy/ELF/strip-unneeded.test
===================================================================
--- test/tools/llvm-objcopy/ELF/strip-unneeded.test
+++ test/tools/llvm-objcopy/ELF/strip-unneeded.test
@@ -5,6 +5,10 @@
# RUN: cmp %t %t1
# RUN: llvm-readobj --symbols %t2 | FileCheck %s
+# Verify that --keep-file-symbols works together with --strip-unneeded
+# RUN: llvm-objcopy --keep-file-symbols --strip-unneeded %t %t2b
+# RUN: llvm-readobj --symbols %t2b | FileCheck %s --check-prefix=FILESYM
+
# RUN: llvm-objcopy --strip-unneeded-symbol=bar \
# RUN: %t %t3
# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefixes=STRIP-BAR,REMAIN
@@ -17,7 +21,7 @@
# RUN: echo "foobaz" >> %t.list.txt
# RUN: echo " # comment " >> %t.list.txt
# RUN: llvm-objcopy --strip-unneeded-symbols %t.list.txt %t %t5
-# RUN: cmp %t2 %t5
+# RUN: cmp %t2b %t5
# RUN: echo " .* # * - remove all " > %t.list2.txt
# RUN: llvm-objcopy --regex --strip-unneeded-symbols %t.list2.txt %t %t6
@@ -124,15 +128,6 @@
#CHECK-NEXT: Section: .text
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
-#CHECK-NEXT: Name: fileSymbol
-#CHECK-NEXT: Value: 0x0
-#CHECK-NEXT: Size: 0
-#CHECK-NEXT: Binding: Local
-#CHECK-NEXT: Type: File
-#CHECK-NEXT: Other: 0
-#CHECK-NEXT: Section: Undefined
-#CHECK-NEXT: }
-#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: sectionSymbol
#CHECK-NEXT: Value: 0x0
#CHECK-NEXT: Size: 0
@@ -161,6 +156,9 @@
#CHECK-NEXT: }
#CHECK-NEXT:]
+#FILESYM: Name: fileSymbol
+#FILESYM-NEXT: Value: 0x0
+
#STRIP-BAR-NOT: Name: bar ({{.*}})
#REMAIN: Name: foobar
#REMAIN: Name: foobaz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61641.198470.patch
Type: text/x-patch
Size: 2202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190507/d1787f40/attachment.bin>
More information about the llvm-commits
mailing list