[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.
llvm-svn: 251027
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
index ebcea9a..75ba12b 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
@@ -113,6 +113,13 @@
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;