diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-12-17 04:54:58 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-12-17 04:54:58 +0000 |
commit | b27bb86ba5eafc6ec7b7fd3fdec836f007b59585 (patch) | |
tree | 30d69264cd6cd43f38177d119d7f7fbdcda323f0 /llvm/lib/MC/MachObjectWriter.cpp | |
parent | f2adf782abb1f50b210d4ff182981140787c81af (diff) | |
download | bcm5719-llvm-b27bb86ba5eafc6ec7b7fd3fdec836f007b59585.tar.gz bcm5719-llvm-b27bb86ba5eafc6ec7b7fd3fdec836f007b59585.zip |
MC/Mach-O: Implement IsSymbolRefDifferenceFullyResolved.
- Unlike for fixups, we always do the "reliable" thing (not just for x86_64).
- Since Darwin 'as' would typically reject things that using this will allow,
we don't need to worry about compatibility.
llvm-svn: 122038
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index e12daa708bc..17615eef697 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -1126,6 +1126,31 @@ public: bool IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B) const { + // The effective address is + // addr(atom(A)) + offset(A) + // - addr(atom(B)) - offset(B) + // and the offsets are not relocatable, so the fixup is fully resolved when + // addr(atom(A)) - addr(atom(B)) == 0. + const MCSymbolData *A_Base = 0, *B_Base = 0; + + // Modified symbol references cannot be resolved. + if (A->getKind() != MCSymbolRefExpr::VK_None || + B->getKind() != MCSymbolRefExpr::VK_None) + return false; + + A_Base = Asm.getAtom(&Asm.getSymbolData(A->getSymbol())); + if (!A_Base) + return false; + + B_Base = Asm.getAtom(&Asm.getSymbolData(B->getSymbol())); + if (!B_Base) + return false; + + // If the atoms are the same, they are guaranteed to have the same address. + if (A_Base == B_Base) + return true; + + // Otherwise, we can't prove this is fully resolved. return false; } |