[llvm-commits] [llvm] r136689 - in /llvm/trunk: include/llvm/Support/ELF.h lib/MC/ELFObjectWriter.cpp lib/MC/ELFObjectWriter.h lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
Roman Divacky
rdivacky at freebsd.org
Tue Aug 2 09:39:50 PDT 2011
> What would be the preferred solution to this? Introduce adjustFixupOffset()
> method in MCELFObjectTargetWriter that would the target classes overwrite
> and which would have the afore mentioned code in
> PPCELFObjectWriter::adjustFixupOffset() ?
like this? tested on X86 and PPC
Index: lib/MC/ELFObjectWriter.h
===================================================================
--- lib/MC/ELFObjectWriter.h (revision 136693)
+++ lib/MC/ELFObjectWriter.h (working copy)
@@ -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 -------------------------------------------===//
Index: lib/MC/ELFObjectWriter.cpp
===================================================================
--- lib/MC/ELFObjectWriter.cpp (revision 136693)
+++ lib/MC/ELFObjectWriter.cpp (working copy)
@@ -447,19 +447,9 @@
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;
ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend);
@@ -1577,6 +1567,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,
More information about the llvm-commits
mailing list