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 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) {