[llvm] r329746 - Recommit r329716 "Add missing nullptr check before getSection() to AArch64MachObjectWriter::recordRelocation"

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 10 12:46:43 PDT 2018


Author: paquette
Date: Tue Apr 10 12:46:43 2018
New Revision: 329746

URL: http://llvm.org/viewvc/llvm-project?rev=329746&view=rev
Log:
Recommit r329716 "Add missing nullptr check before getSection() to AArch64MachObjectWriter::recordRelocation"

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.


Added:
    llvm/trunk/test/MC/AArch64/arm64-no-section.ll
Modified:
    llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp

Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp?rev=329746&r1=329745&r2=329746&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Tue Apr 10 12:46:43 2018
@@ -306,6 +306,15 @@ void AArch64MachObjectWriter::recordRelo
     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();

Added: llvm/trunk/test/MC/AArch64/arm64-no-section.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/arm64-no-section.ll?rev=329746&view=auto
==============================================================================
--- llvm/trunk/test/MC/AArch64/arm64-no-section.ll (added)
+++ llvm/trunk/test/MC/AArch64/arm64-no-section.ll Tue Apr 10 12:46:43 2018
@@ -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
+}




More information about the llvm-commits mailing list