[llvm-commits] [llvm] r136905 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h
Roman Divacky
rdivacky at freebsd.org
Thu Aug 4 12:08:20 PDT 2011
Author: rdivacky
Date: Thu Aug 4 14:08:19 2011
New Revision: 136905
URL: http://llvm.org/viewvc/llvm-project?rev=136905&view=rev
Log:
Introduce adjustFixupOffset that adjusts the fixup offset of a relocation.
This is meant to be overriden by backends. Implement an override on PowerPC
which adjusts the offset by 2 for ha16/lo16 relocation kinds. This removes
a commented out hack and enables hello world to be compiled on PowerPC.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/ELFObjectWriter.h
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=136905&r1=136904&r2=136905&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Aug 4 14:08:19 2011
@@ -447,18 +447,8 @@
uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) +
Fixup.getOffset();
-#if 0
- // TODO: This is necessary on PPC32 but it must be implemented
- // in a different way.
- switch ((unsigned)Fixup.getKind()) {
- case PPC::fixup_ppc_ha16:
- case PPC::fixup_ppc_lo16:
- RelocOffset += 2;
- break;
- default:
- break;
- }
-#endif
+
+ adjustFixupOffset(Fixup, RelocOffset);
if (!hasRelocationAddend())
Addend = 0;
@@ -1583,6 +1573,18 @@
return Type;
}
+void
+PPCELFObjectWriter::adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset) {
+ switch ((unsigned)Fixup.getKind()) {
+ case PPC::fixup_ppc_ha16:
+ case PPC::fixup_ppc_lo16:
+ RelocOffset += 2;
+ break;
+ default:
+ break;
+ }
+}
+
//===- MBlazeELFObjectWriter -------------------------------------------===//
MBlazeELFObjectWriter::MBlazeELFObjectWriter(MCELFObjectTargetWriter *MOTW,
Modified: llvm/trunk/lib/MC/ELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.h?rev=136905&r1=136904&r2=136905&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.h (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.h Thu Aug 4 14:08:19 2011
@@ -347,6 +347,7 @@
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend) = 0;
+ virtual void adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset) { }
};
//===- X86ELFObjectWriter -------------------------------------------===//
@@ -408,6 +409,7 @@
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend);
+ virtual void adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset);
};
//===- MBlazeELFObjectWriter -------------------------------------------===//
More information about the llvm-commits
mailing list