[llvm] r361231 - [llvm-objcopy] Strip file symbols with --strip-unneeded
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 02:09:33 PDT 2019
Author: evgeny777
Date: Tue May 21 02:09:33 2019
New Revision: 361231
URL: http://llvm.org/viewvc/llvm-project?rev=361231&view=rev
Log:
[llvm-objcopy] Strip file symbols with --strip-unneeded
Differential revision: https://reviews.llvm.org/D61641
Modified:
llvm/trunk/test/tools/llvm-objcopy/ELF/strip-unneeded.test
llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-unneeded.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/strip-unneeded.test?rev=361231&r1=361230&r2=361231&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-unneeded.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-unneeded.test Tue May 21 02:09:33 2019
@@ -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 @@ Symbols:
#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 @@ Symbols:
#CHECK-NEXT: }
#CHECK-NEXT:]
+#FILESYM: Name: fileSymbol
+#FILESYM-NEXT: Value: 0x0
+
#STRIP-BAR-NOT: Name: bar ({{.*}})
#REMAIN: Name: foobar
#REMAIN: Name: foobaz
Modified: llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp?rev=361231&r1=361230&r2=361231&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/ELF/ELFObjcopy.cpp Tue May 21 02:09:33 2019
@@ -324,7 +324,7 @@ static void replaceDebugSections(
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) {
More information about the llvm-commits
mailing list