summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MachObjectWriter.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-12-22 16:19:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-12-22 16:19:24 +0000
commit9ccf843a61bf7db4c57467c5c5761d66c1a87e52 (patch)
tree10f09537ba34dab83b468abc8dfc96263c709ffa /llvm/lib/MC/MachObjectWriter.cpp
parent56f13732e2326034bd0804d5cc0e1af13227987d (diff)
downloadbcm5719-llvm-9ccf843a61bf7db4c57467c5c5761d66c1a87e52.tar.gz
bcm5719-llvm-9ccf843a61bf7db4c57467c5c5761d66c1a87e52.zip
MC/Mach-O/ARM: Add enough relocation logic to get BR24 relocations.
llvm-svn: 122407
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 97d8afb3380..93a3dcf8d91 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -24,6 +24,7 @@
#include "llvm/Target/TargetAsmBackend.h"
// FIXME: Gross.
+#include "../Target/ARM/ARMFixupKinds.h"
#include "../Target/X86/X86FixupKinds.h"
#include <vector>
@@ -843,12 +844,33 @@ public:
Relocations[Fragment->getParent()].push_back(MRE);
}
+ static bool getARMFixupKindMachOInfo(unsigned Kind, bool &Is24BitBranch,
+ unsigned &Log2Size) {
+ switch (Kind) {
+ default:
+ return false;
+
+ // Handle 24-bit branch kinds.
+ case ARM::fixup_arm_ldst_pcrel_12:
+ case ARM::fixup_arm_pcrel_10:
+ case ARM::fixup_arm_adr_pcrel_12:
+ case ARM::fixup_arm_branch:
+ Is24BitBranch = true;
+ // Report as 'long', even though that is not quite accurate.
+ Log2Size = llvm::Log2_32(4);
+ return true;
+ }
+ }
void RecordARMRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFragment *Fragment, const MCFixup &Fixup,
MCValue Target, uint64_t &FixedValue) {
unsigned IsPCRel = isFixupKindPCRel(Asm, Fixup.getKind());
- // FIXME: Eliminate this!
- unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
+ unsigned Log2Size;
+ bool Is24BitBranch;
+ if (!getARMFixupKindMachOInfo(Fixup.getKind(), Is24BitBranch, Log2Size)) {
+ report_fatal_error("unknown ARM fixup kind!");
+ return;
+ }
// If this is a difference or a defined symbol plus an offset, then we need
// a scattered relocation entry. Differences always require scattered
@@ -912,7 +934,8 @@ public:
if (IsPCRel)
FixedValue -= getSectionAddress(Fragment->getParent());
- Type = macho::RIT_Vanilla;
+ // Determine the appropriate type based on the fixup kind.
+ Type = Is24BitBranch ? macho::RIT_ARM_Branch24Bit : macho::RIT_Vanilla;
}
// struct relocation_info (8 bytes)
OpenPOWER on IntegriCloud