mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Factor symbol value computation into a function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9cf23a9ab4
commit
2c6ec31df6
@ -388,25 +388,33 @@ void ELFObjectWriterImpl::WriteSymbolEntry(MCDataFragment *F, uint64_t name,
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t SymbolValue(MCSymbolData &Data, const MCAsmLayout &Layout) {
|
||||
if (Data.isCommon() && Data.isExternal())
|
||||
return Data.getCommonAlignment();
|
||||
|
||||
const MCSymbol &Symbol = Data.getSymbol();
|
||||
if (!Symbol.isInSection())
|
||||
return 0;
|
||||
|
||||
if (!Data.isCommon() && !(Data.getFlags() & ELF_STB_Weak))
|
||||
if (MCFragment *FF = Data.getFragment())
|
||||
return Layout.getSymbolAddress(&Data) -
|
||||
Layout.getSectionAddress(FF->getParent());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD,
|
||||
const MCAsmLayout &Layout) {
|
||||
MCSymbolData &Data = *MSD.SymbolData;
|
||||
uint8_t Info = (Data.getFlags() & 0xff);
|
||||
uint8_t Other = ((Data.getFlags() & 0xf00) >> ELF_STV_Shift);
|
||||
uint64_t Value = 0;
|
||||
uint64_t Value = SymbolValue(Data, Layout);
|
||||
uint64_t Size = 0;
|
||||
const MCExpr *ESize;
|
||||
|
||||
if (Data.isCommon() && Data.isExternal())
|
||||
Value = Data.getCommonAlignment();
|
||||
|
||||
assert(!(Data.isCommon() && !Data.isExternal()));
|
||||
|
||||
if (!Data.isCommon() && !(Data.getFlags() & ELF_STB_Weak))
|
||||
if (MCFragment *FF = Data.getFragment())
|
||||
Value = Layout.getSymbolAddress(&Data) -
|
||||
Layout.getSectionAddress(FF->getParent());
|
||||
|
||||
ESize = Data.getSize();
|
||||
if (Data.getSize()) {
|
||||
MCValue Res;
|
||||
|
Loading…
x
Reference in New Issue
Block a user