MC/Mach-O: Fix another mismatch with .weak_definition, we shouldn't use a

scattered relocation entry with a .weak_definition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103443 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2010-05-10 23:15:20 +00:00
parent e9460ec057
commit a8251fac10
2 changed files with 44 additions and 34 deletions

View File

@ -740,15 +740,24 @@ public:
// If this is a difference or a defined symbol plus an offset, then we need
// a scattered relocation entry.
// Differences always require scattered relocations.
if (Target.getSymB())
return RecordScatteredRelocation(Asm, Layout, Fragment, Fixup,
Target, FixedValue);
// Get the symbol data, if any.
MCSymbolData *SD = 0;
if (Target.getSymA())
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
// If this is an internal relocation with an offset, it also needs a
// scattered relocation entry.
uint32_t Offset = Target.getConstant();
if (IsPCRel)
Offset += 1 << Log2Size;
if (Target.getSymB() ||
(Target.getSymA() && !Target.getSymA()->getSymbol().isUndefined() &&
Offset)) {
RecordScatteredRelocation(Asm, Layout, Fragment, Fixup,Target,FixedValue);
return;
}
if (Offset && SD && !doesSymbolRequireExternRelocation(SD))
return RecordScatteredRelocation(Asm, Layout, Fragment, Fixup,
Target, FixedValue);
// See <reloc.h>.
uint32_t Address = Layout.getFragmentOffset(Fragment) + Fixup.Offset;
@ -765,9 +774,6 @@ public:
Type = RIT_Vanilla;
Value = 0;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
MCSymbolData *SD = &Asm.getSymbolData(*Symbol);
// Check whether we need an external or internal relocation.
if (doesSymbolRequireExternRelocation(SD)) {
IsExtern = 1;