summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2018-07-26 20:05:31 +0000
committerStephen Hines <srhines@google.com>2018-07-26 20:05:31 +0000
commite6e75bf84c94e03313594c1b5faf2b8065969c39 (patch)
treef5e01740d9cfce74e014d80b868aef5f6c933515 /llvm/tools/llvm-objcopy/llvm-objcopy.cpp
parentd742d645a1fc6630e462c5702c4429368cc41077 (diff)
downloadbcm5719-llvm-e6e75bf84c94e03313594c1b5faf2b8065969c39.tar.gz
bcm5719-llvm-e6e75bf84c94e03313594c1b5faf2b8065969c39.zip
Handle the lack of a symbol table correctly.
Summary: These two cases will trigger a dereference on a nullptr, since the SymbolTable can be nonexistent for a given library, in addition to just being empty. Reviewers: alexshap Reviewed By: alexshap Subscribers: meikeb, kongyi, chh, jakehehrlich, llvm-commits, pirama Differential Revision: https://reviews.llvm.org/D49534 llvm-svn: 338062
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/llvm-objcopy.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 3a25e3f690b..4ccc67cc75d 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -396,7 +396,8 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
// 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 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
// (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;
OpenPOWER on IntegriCloud