summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2007-02-28 07:40:50 +0000
committerNate Begeman <natebegeman@mac.com>2007-02-28 07:40:50 +0000
commite0232ec70651aebe0c33d478cce20ca064910ad3 (patch)
tree9c94d05cfec9ff5160304ef6a020a91ee6ccd116 /llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
parent152bfa103ef42bee4e735ad0714f0068bcf15341 (diff)
downloadbcm5719-llvm-e0232ec70651aebe0c33d478cce20ca064910ad3.tar.gz
bcm5719-llvm-e0232ec70651aebe0c33d478cce20ca064910ad3.zip
More Mach-O writer improvements.
llvm-svn: 34740
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp b/llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
index de3960d54f4..5e2dc9ea658 100644
--- a/llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCMachOWriterInfo.cpp
@@ -35,13 +35,11 @@ unsigned PPCMachOWriterInfo::GetTargetRelocation(MachineRelocation &MR,
unsigned ToIdx,
OutputBuffer &RelocOut,
OutputBuffer &SecOut,
- bool Scattered) const {
+ bool Scattered,
+ bool isExtern) const {
unsigned NumRelocs = 0;
uint64_t Addr = 0;
- // Keep track of whether or not this is an externally defined relocation.
- bool isExtern = false;
-
// Get the address of whatever it is we're relocating, if possible.
if (!isExtern)
Addr = (uintptr_t)MR.getResultPointer() + ToAddr;
@@ -83,12 +81,24 @@ unsigned PPCMachOWriterInfo::GetTargetRelocation(MachineRelocation &MR,
break;
case PPC::reloc_pcrel_bx:
{
+ // FIXME: Presumably someday we will need to branch to other, non-extern
+ // functions too. Need to figure out some way to distinguish between
+ // target is BB and target is function.
+ if (isExtern) {
+ MachORelocation BR24(MR.getMachineCodeOffset(), ToIdx, true, 2,
+ isExtern, PPC_RELOC_BR24, Scattered,
+ (intptr_t)MR.getMachineCodeOffset());
+ RelocOut.outword(BR24.getAddress());
+ RelocOut.outword(BR24.getPackedFields());
+ ++NumRelocs;
+ }
+
Addr -= MR.getMachineCodeOffset();
Addr >>= 2;
Addr &= 0xFFFFFF;
Addr <<= 2;
Addr |= (SecOut[MR.getMachineCodeOffset()] << 24);
-
+ Addr |= (SecOut[MR.getMachineCodeOffset()+3] & 0x3);
SecOut.fixword(Addr, MR.getMachineCodeOffset());
break;
}
OpenPOWER on IntegriCloud