summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-04-10 15:53:28 +0000
committerJessica Paquette <jpaquette@apple.com>2018-04-10 15:53:28 +0000
commite4b90d82a0ed8cad2949d83839fcf023ab08ed97 (patch)
tree1999d89cddcdd68b4d90e64908c1a7510ab1fcd0 /llvm/lib/Target
parentb1c3b22b4cc0a6ecf24d9a22b506ebfec2e3e8ee (diff)
downloadbcm5719-llvm-e4b90d82a0ed8cad2949d83839fcf023ab08ed97.tar.gz
bcm5719-llvm-e4b90d82a0ed8cad2949d83839fcf023ab08ed97.zip
Add missing nullptr check to AArch64MachObjectWriter::recordRelocation
There was missing nullptr check before a call to getSection() in recordRelocation. This would result in a segfault in code like the attached test. This adds the missing check and a test which makes sure we get the expected error output. llvm-svn: 329716
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
index d52c58e47f9..a8e0d0563c7 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
@@ -305,7 +305,8 @@ void AArch64MachObjectWriter::recordRelocation(
bool CanUseLocalRelocation =
canUseLocalRelocation(Section, *Symbol, Log2Size);
- if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) {
+ if (Symbol->isTemporary() && Symbol->isInSection() &&
+ (Value || !CanUseLocalRelocation)) {
const MCSection &Sec = Symbol->getSection();
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Symbol->setUsedInReloc();
OpenPOWER on IntegriCloud