summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2011-11-23 22:18:04 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2011-11-23 22:18:04 +0000
commitf5ddf13f79b1d83c14a8a9b6c8df3f2f053a4088 (patch)
tree93892c51dea4ec5d419e522aa59fde588471806e /llvm/lib/MC
parent4f9a8081c370543c568a098138bcb785a7143469 (diff)
downloadbcm5719-llvm-f5ddf13f79b1d83c14a8a9b6c8df3f2f053a4088.tar.gz
bcm5719-llvm-f5ddf13f79b1d83c14a8a9b6c8df3f2f053a4088.zip
This patch addresses gp relative fixups/relocations for jump tables.
llvm-svn: 145112
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp9
-rw-r--r--llvm/lib/MC/ELFObjectWriter.h2
-rw-r--r--llvm/lib/MC/MCAsmBackend.cpp16
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp10
4 files changed, 31 insertions, 6 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 4491d4b16b6..bd28069a315 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1825,6 +1825,12 @@ MipsELFObjectWriter::MipsELFObjectWriter(MCELFObjectTargetWriter *MOTW,
MipsELFObjectWriter::~MipsELFObjectWriter() {}
+// FIXME: get the real EABI Version from the Triple.
+void MipsELFObjectWriter::WriteEFlags() {
+ Write32(ELF::EF_MIPS_NOREORDER |
+ ELF::EF_MIPS_ARCH_32R2);
+}
+
unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup,
bool IsPCRel,
@@ -1840,6 +1846,9 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target,
case FK_Data_4:
Type = ELF::R_MIPS_32;
break;
+ case FK_GPRel_4:
+ Type = ELF::R_MIPS_GPREL32;
+ break;
case Mips::fixup_Mips_GPREL16:
Type = ELF::R_MIPS_GPREL16;
break;
diff --git a/llvm/lib/MC/ELFObjectWriter.h b/llvm/lib/MC/ELFObjectWriter.h
index ca6cdfc5ce1..78382065dbc 100644
--- a/llvm/lib/MC/ELFObjectWriter.h
+++ b/llvm/lib/MC/ELFObjectWriter.h
@@ -442,6 +442,8 @@ class ELFObjectWriter : public MCObjectWriter {
bool IsLittleEndian);
virtual ~MipsELFObjectWriter();
+ virtual void WriteEFlags();
+
protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol,
diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp
index 2c150f456cf..936ed55e54d 100644
--- a/llvm/lib/MC/MCAsmBackend.cpp
+++ b/llvm/lib/MC/MCAsmBackend.cpp
@@ -21,14 +21,18 @@ MCAsmBackend::~MCAsmBackend() {
const MCFixupKindInfo &
MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
static const MCFixupKindInfo Builtins[] = {
- { "FK_Data_1", 0, 8, 0 },
- { "FK_Data_2", 0, 16, 0 },
- { "FK_Data_4", 0, 32, 0 },
- { "FK_Data_8", 0, 64, 0 },
- { "FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel },
+ { "FK_Data_1", 0, 8, 0 },
+ { "FK_Data_2", 0, 16, 0 },
+ { "FK_Data_4", 0, 32, 0 },
+ { "FK_Data_8", 0, 64, 0 },
+ { "FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel },
{ "FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
{ "FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
- { "FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel }
+ { "FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel },
+ { "FK_GPRel_1", 0, 8, 0 },
+ { "FK_GPRel_2", 0, 16, 0 },
+ { "FK_GPRel_4", 0, 32, 0 },
+ { "FK_GPRel_8", 0, 64, 0 }
};
assert((size_t)Kind <= sizeof(Builtins) / sizeof(Builtins[0]) &&
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index a04ae0812a3..90c957f7be8 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -245,6 +245,16 @@ void MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset,
EmitFill(Res, Value, 0);
}
+// Associate GPRel32 fixup with data and resize data area
+void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) {
+ MCDataFragment *DF = getOrCreateDataFragment();
+
+ DF->addFixup(MCFixup::Create(DF->getContents().size(),
+ Value,
+ FK_GPRel_4));
+ DF->getContents().resize(DF->getContents().size() + 4, 0);
+}
+
void MCObjectStreamer::Finish() {
// Dump out the dwarf file & directory tables and line tables.
if (getContext().hasDwarfFiles())
OpenPOWER on IntegriCloud