OSDN Git Service

Recommit r329716 "Add missing nullptr check before getSection() to AArch64MachObjectW...
authorJessica Paquette <jpaquette@apple.com>
Tue, 10 Apr 2018 19:46:43 +0000 (19:46 +0000)
committerJessica Paquette <jpaquette@apple.com>
Tue, 10 Apr 2018 19:46:43 +0000 (19:46 +0000)
This commit fixes the bot failures that were coming up before with r329716.

The fix was to move the check for "isInSection()" inside of the if condition
and emit the error there instead of waiting to get past the unreachable statement.

This should work in debug and release builds now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329746 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
test/MC/AArch64/arm64-no-section.ll [new file with mode: 0644]

index d52c58e..bcbbcd6 100644 (file)
@@ -306,6 +306,15 @@ void AArch64MachObjectWriter::recordRelocation(
     bool CanUseLocalRelocation =
         canUseLocalRelocation(Section, *Symbol, Log2Size);
     if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) {
+      // Make sure that the symbol is actually in a section here. If it isn't,
+      // emit an error and exit.
+      if (!Symbol->isInSection()) {
+        Asm.getContext().reportError(
+            Fixup.getLoc(),
+            "unsupported relocation of local symbol '" + Symbol->getName() +
+                "'. Must have non-local symbol earlier in section.");
+        return;
+      }
       const MCSection &Sec = Symbol->getSection();
       if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
         Symbol->setUsedInReloc();
diff --git a/test/MC/AArch64/arm64-no-section.ll b/test/MC/AArch64/arm64-no-section.ll
new file mode 100644 (file)
index 0000000..94153a5
--- /dev/null
@@ -0,0 +1,10 @@
+; RUN: not llc -mtriple=aarch64-darwin-- -filetype=obj %s -o /dev/null 2>&1 >/dev/null | FileCheck %s
+; CHECK: error: unsupported relocation of local symbol 'L_foo_end'.
+; CHECK-SAME: 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 {
+  call void asm sideeffect "b L_foo_end\0A", ""()
+  ret void
+}