[llvm] r251027 - [PPC] Fix PR24686 by failing assembly for an invalid relocation

Bill Schmidt via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 08:53:44 PDT 2015


Author: wschmidt
Date: Thu Oct 22 10:53:44 2015
New Revision: 251027

URL: http://llvm.org/viewvc/llvm-project?rev=251027&view=rev
Log:
[PPC] Fix PR24686 by failing assembly for an invalid relocation

PR24686 identifies a problem where a relocation expression is invalid
when not all of the symbols in the expression can be locally
resolved.  This causes the compiler to request a PC-relative half16ds
relocation, which is nonsensical for PowerPC.  This patch recognizes
this situation and ensures we fail the assembly cleanly.

Test case provided by Anton Blanchard.

Added:
    llvm/trunk/test/MC/PowerPC/pr24686.s
Modified:
    llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp

Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp?rev=251027&r1=251026&r2=251027&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp Thu Oct 22 10:53:44 2015
@@ -113,6 +113,13 @@ unsigned PPCELFObjectWriter::GetRelocTyp
         break;
       }
       break;
+    case PPC::fixup_ppc_half16ds: {
+      raw_ostream &OS = *(new raw_fd_ostream(2, false));
+      Target.print(OS);
+      OS << "\n";
+      report_fatal_error("Invalid PC-relative half16ds relocation");
+      break;
+    }
     case FK_Data_4:
     case FK_PCRel_4:
       Type = ELF::R_PPC_REL32;

Added: llvm/trunk/test/MC/PowerPC/pr24686.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/pr24686.s?rev=251027&view=auto
==============================================================================
--- llvm/trunk/test/MC/PowerPC/pr24686.s (added)
+++ llvm/trunk/test/MC/PowerPC/pr24686.s Thu Oct 22 10:53:44 2015
@@ -0,0 +1,7 @@
+# RUN: not llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj %s \
+# RUN: 2>&1 | FileCheck %s
+        
+_stext:
+ld %r5, p_end - _stext(%r5)
+
+# CHECK: LLVM ERROR: Invalid PC-relative half16ds relocation




More information about the llvm-commits mailing list