llvm.org GIT mirror llvm / 4a9fe5a
[llvm-objcopy] Strip file symbols with --strip-unneeded Differential revision: https://reviews.llvm.org/D61641 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361231 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Leviant 5 months ago
2 changed file(s) with 9 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
33 # Verify that llvm-objcopy has not modified the input.
44 # RUN: cmp %t %t1
55 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
6
7 # Verify that --keep-file-symbols works together with --strip-unneeded
8 # RUN: llvm-objcopy --keep-file-symbols --strip-unneeded %t %t2b
9 # RUN: llvm-readobj --symbols %t2b | FileCheck %s --check-prefix=FILESYM
610
711 # RUN: llvm-objcopy --strip-unneeded-symbol=bar \
812 # RUN: %t %t3
1620 # RUN: echo "foobaz" >> %t.list.txt
1721 # RUN: echo " # comment " >> %t.list.txt
1822 # RUN: llvm-objcopy --strip-unneeded-symbols %t.list.txt %t %t5
19 # RUN: cmp %t2 %t5
23 # RUN: cmp %t2b %t5
2024
2125 # RUN: echo " .* # * - remove all " > %t.list2.txt
2226 # RUN: llvm-objcopy --regex --strip-unneeded-symbols %t.list2.txt %t %t6
123127 #CHECK-NEXT: Section: .text
124128 #CHECK-NEXT: }
125129 #CHECK-NEXT: Symbol {
126 #CHECK-NEXT: Name: fileSymbol
127 #CHECK-NEXT: Value: 0x0
128 #CHECK-NEXT: Size: 0
129 #CHECK-NEXT: Binding: Local
130 #CHECK-NEXT: Type: File
131 #CHECK-NEXT: Other: 0
132 #CHECK-NEXT: Section: Undefined
133 #CHECK-NEXT: }
134 #CHECK-NEXT: Symbol {
135130 #CHECK-NEXT: Name: sectionSymbol
136131 #CHECK-NEXT: Value: 0x0
137132 #CHECK-NEXT: Size: 0
160155 #CHECK-NEXT: }
161156 #CHECK-NEXT:]
162157
158 #FILESYM: Name: fileSymbol
159 #FILESYM-NEXT: Value: 0x0
160
163161 #STRIP-BAR-NOT: Name: bar ({{.*}})
164162 #REMAIN: Name: foobar
165163 #REMAIN: Name: foobaz
323323 static bool isUnneededSymbol(const Symbol &Sym) {
324324 return !Sym.Referenced &&
325325 (Sym.Binding == STB_LOCAL || Sym.getShndx() == SHN_UNDEF) &&
326 Sym.Type != STT_FILE && Sym.Type != STT_SECTION;
326 Sym.Type != STT_SECTION;
327327 }
328328
329329 static Error updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) {