mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Don't crash in a strange .size directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115684 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
748a2fe917
commit
62fed8bd38
@ -445,12 +445,22 @@ void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD,
|
||||
const MCBinaryExpr *BE = static_cast<const MCBinaryExpr *>(ESize);
|
||||
|
||||
if (BE->EvaluateAsRelocatable(Res, &Layout)) {
|
||||
MCSymbolData &A =
|
||||
Layout.getAssembler().getSymbolData(Res.getSymA()->getSymbol());
|
||||
MCSymbolData &B =
|
||||
Layout.getAssembler().getSymbolData(Res.getSymB()->getSymbol());
|
||||
uint64_t AddressA = 0;
|
||||
uint64_t AddressB = 0;
|
||||
const MCSymbol &SymA = Res.getSymA()->getSymbol();
|
||||
const MCSymbol &SymB = Res.getSymB()->getSymbol();
|
||||
|
||||
Size = Layout.getSymbolAddress(&A) - Layout.getSymbolAddress(&B);
|
||||
if (SymA.isDefined()) {
|
||||
MCSymbolData &A = Layout.getAssembler().getSymbolData(SymA);
|
||||
AddressA = Layout.getSymbolAddress(&A);
|
||||
}
|
||||
|
||||
if (SymB.isDefined()) {
|
||||
MCSymbolData &B = Layout.getAssembler().getSymbolData(SymB);
|
||||
AddressB = Layout.getSymbolAddress(&B);
|
||||
}
|
||||
|
||||
Size = AddressA - AddressB;
|
||||
}
|
||||
} else if (ESize->getKind() == MCExpr::Constant) {
|
||||
Size = static_cast<const MCConstantExpr *>(ESize)->getValue();
|
||||
|
9
test/MC/ELF/size.s
Normal file
9
test/MC/ELF/size.s
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
|
||||
|
||||
// Mostly a test that this doesn't crash anymore.
|
||||
|
||||
// CHECK: # Symbol 4
|
||||
// CHECK-NEXT: (('st_name', 1) # 'foo'
|
||||
// CHECK-NEXT: ('st_bind', 1)
|
||||
|
||||
.size foo, .Lbar-foo
|
Loading…
x
Reference in New Issue
Block a user