summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp3
-rw-r--r--llvm/test/MC/AArch64/arm64-no-section.ll10
2 files changed, 12 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();
diff --git a/llvm/test/MC/AArch64/arm64-no-section.ll b/llvm/test/MC/AArch64/arm64-no-section.ll
new file mode 100644
index 00000000000..928453c3876
--- /dev/null
+++ b/llvm/test/MC/AArch64/arm64-no-section.ll
@@ -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
+}
OpenPOWER on IntegriCloud