[PATCH] D49534: Handle the lack of a symbol table correctly.
Stephen Hines via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 26 13:05:58 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338062: Handle the lack of a symbol table correctly. (authored by srhines, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D49534
Files:
llvm/trunk/test/tools/llvm-objcopy/strip-all.test
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Index: llvm/trunk/test/tools/llvm-objcopy/strip-all.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all.test
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all.test
@@ -35,6 +35,13 @@
# RUN: llvm-strip --strip-all %t8
# RUN: cmp %t2 %t8
+# Verify that a non-existent symbol table (after first call to llvm-strip)
+# can be handled correctly.
+# RUN: cp %t %t9
+# RUN: llvm-strip --strip-all -keep=unavailable_symbol %t9
+# RUN: llvm-strip --strip-all -keep=unavailable_symbol %t9
+# RUN: cmp %t2 %t9
+
!ELF
FileHeader:
Class: ELFCLASS64
Index: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -396,7 +396,8 @@
// Keep special sections.
if (Obj.SectionNames == &Sec)
return false;
- if (Obj.SymbolTable == &Sec || Obj.SymbolTable->getStrTab() == &Sec)
+ if (Obj.SymbolTable == &Sec ||
+ (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec))
return false;
// Remove everything else.
@@ -421,7 +422,7 @@
// (equivalently, the updated symbol table is not empty)
// the symbol table and the string table should not be removed.
if ((!Config.SymbolsToKeep.empty() || Config.KeepFileSymbols) &&
- !Obj.SymbolTable->empty()) {
+ Obj.SymbolTable && !Obj.SymbolTable->empty()) {
RemovePred = [&Obj, RemovePred](const SectionBase &Sec) {
if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab())
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49534.157554.patch
Type: text/x-patch
Size: 1672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180726/e2ba4242/attachment.bin>
More information about the llvm-commits
mailing list