forked from OSchip/llvm-project
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
This commit is contained in:
parent
b1c3b22b4c
commit
e4b90d82a0
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
; RUN: llc -mtriple=aarch64-darwin-- -filetype=obj %s -o -
|
||||
; CHECK: <inline asm>:1:2: error: unsupported relocation of local symbol
|
||||
; CHECK-SAME: 'L_foo_end'. Must have non-local symbol earlier in section.
|
||||
|
||||
; Make sure that we emit an error when we try to reference something that
|
||||
; doesn't belong to a section.
|
||||
define void @foo() local_unnamed_addr {
|
||||
tail call void asm sideeffect "b L_foo_end\0A", ""()
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue