mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
Move ELF to HasReliableSymbolDifference=true. Also take the opportunity to put
symbols defined in merge sections in independent atoms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -487,6 +487,13 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F,
|
||||
}
|
||||
}
|
||||
|
||||
static const MCSymbolData *getAtom(const MCSymbolData &SD) {
|
||||
if (!SD.getFragment())
|
||||
return 0;
|
||||
|
||||
return SD.getFragment()->getAtom();
|
||||
}
|
||||
|
||||
// FIXME: this is currently X86/X86_64 only
|
||||
void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
||||
const MCAsmLayout &Layout,
|
||||
@ -502,7 +509,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
||||
if (!Target.isAbsolute()) {
|
||||
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
|
||||
MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||
const MCSymbolData *Base = Asm.getAtom(Layout, &SD);
|
||||
const MCSymbolData *Base = getAtom(SD);
|
||||
MCFragment *F = SD.getFragment();
|
||||
|
||||
// Avoid relocations for cases like jumps and calls in the same file.
|
||||
@ -515,7 +522,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
||||
}
|
||||
|
||||
if (Base) {
|
||||
if (F && !SD.isExternal()) {
|
||||
if (Base != &SD) {
|
||||
Index = F->getParent()->getOrdinal() + LocalSymbolData.size() + 1;
|
||||
|
||||
MCSectionData *FSD = F->getParent();
|
||||
@ -523,8 +530,6 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
||||
Value += Layout.getSymbolAddress(&SD) - Layout.getSectionAddress(FSD);
|
||||
} else
|
||||
Index = getSymbolIndexInSymbolTable(Asm, Symbol);
|
||||
if (Base != &SD)
|
||||
Value += Layout.getSymbolAddress(&SD) - Layout.getSymbolAddress(Base);
|
||||
Addend = Value;
|
||||
// Compensate for the addend on i386.
|
||||
if (Is64Bit)
|
||||
@ -537,11 +542,14 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
|
||||
|
||||
MCSectionData *FSD = F->getParent();
|
||||
// Offset of the symbol in the section
|
||||
Addend = Layout.getSymbolAddress(&SD) - Layout.getSectionAddress(FSD);
|
||||
Value += Layout.getSymbolAddress(&SD) - Layout.getSectionAddress(FSD);
|
||||
} else {
|
||||
FixedValue = Value;
|
||||
return;
|
||||
Index = getSymbolIndexInSymbolTable(Asm, Symbol);
|
||||
}
|
||||
Addend = Value;
|
||||
// Compensate for the addend on i386.
|
||||
if (Is64Bit)
|
||||
Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user