MC tweak symbol difference resolution for non-local symbols.
When the non-local symbol in the expression is in the same fragment
as the second symbol, the assembler can still evaluate the expression
without needing a relocation.
For example, on ARM:
_foo:
ldr lr, (_foo - 4)
rdar://10348687
llvm-svn: 148341
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index e016f09..ce222b7 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -590,8 +590,8 @@
// assembler locals.
if (!Asm.getBackend().hasReliableSymbolDifference()) {
- if ((!SA.isTemporary() && Asm.getSubsectionsViaSymbols()) ||
- !SA.isInSection() || &SecA != &SecB)
+ if (!SA.isInSection() || &SecA != &SecB ||
+ (!SA.isTemporary() && &FB != Asm.getSymbolData(SA).getFragment()))
return false;
return true;
}