[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 19 04:06:05 PDT 2018
srhines updated this revision to Diff 156230.
srhines added a comment.
- Fix positional output argument for llvm-strip.
Repository:
rL LLVM
https://reviews.llvm.org/D49534
Files:
test/tools/llvm-objcopy/strip-all.test
tools/llvm-objcopy/llvm-objcopy.cpp
Index: tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- tools/llvm-objcopy/llvm-objcopy.cpp
+++ tools/llvm-objcopy/llvm-objcopy.cpp
@@ -389,7 +389,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.
@@ -414,7 +415,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;
@@ -649,7 +650,7 @@
CopyConfig Config;
Config.InputFilename = Positional[0];
Config.OutputFilename =
- InputArgs.getLastArgValue(STRIP_output, Positional[0]);
+ InputArgs.getLastArgValue(STRIP_output, Positional[Positional.size()-1]);
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
Index: test/tools/llvm-objcopy/strip-all.test
===================================================================
--- test/tools/llvm-objcopy/strip-all.test
+++ test/tools/llvm-objcopy/strip-all.test
@@ -35,6 +35,19 @@
# 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
+
+# Verify that a positional output file leaves the input unchanged.
+# RUN: cp %t %t10
+# RUN: llvm-strip --strip-all %t10 %t11
+# RUN: cmp %t %t10
+# RUN: cmp %t2 %t11
+
!ELF
FileHeader:
Class: ELFCLASS64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49534.156230.patch
Type: text/x-patch
Size: 2095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180719/3e31fe61/attachment.bin>
More information about the llvm-commits
mailing list