mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Add some limited support for labels in org directives. Hopefully enough to fix
PR9245. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126091 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8e04fc3adf
commit
f7ad048f1e
@ -242,7 +242,23 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
|
||||
|
||||
void MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset,
|
||||
unsigned char Value) {
|
||||
new MCOrgFragment(*Offset, Value, getCurrentSectionData());
|
||||
int64_t Res;
|
||||
if (Offset->EvaluateAsAbsolute(Res, getAssembler())) {
|
||||
new MCOrgFragment(*Offset, Value, getCurrentSectionData());
|
||||
return;
|
||||
}
|
||||
|
||||
MCSymbol *CurrentPos = getContext().CreateTempSymbol();
|
||||
EmitLabel(CurrentPos);
|
||||
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
|
||||
const MCExpr *Ref =
|
||||
MCSymbolRefExpr::Create(CurrentPos, Variant, getContext());
|
||||
const MCExpr *Delta =
|
||||
MCBinaryExpr::Create(MCBinaryExpr::Sub, Offset, Ref, getContext());
|
||||
|
||||
if (!Delta->EvaluateAsAbsolute(Res, getAssembler()))
|
||||
report_fatal_error("expected assembly-time absolute expression");
|
||||
EmitFill(Res, Value, 0);
|
||||
}
|
||||
|
||||
void MCObjectStreamer::Finish() {
|
||||
|
13
test/MC/ELF/org.s
Normal file
13
test/MC/ELF/org.s
Normal file
@ -0,0 +1,13 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
|
||||
|
||||
.zero 4
|
||||
foo:
|
||||
.zero 4
|
||||
.org foo+16
|
||||
|
||||
// CHECK: (('sh_name', 0x00000001) # '.text'
|
||||
// CHECK-NEXT: ('sh_type',
|
||||
// CHECK-NEXT: ('sh_flags',
|
||||
// CHECK-NEXT: ('sh_addr',
|
||||
// CHECK-NEXT: ('sh_offset'
|
||||
// CHECK-NEXT: ('sh_size', 0x00000014)
|
Loading…
Reference in New Issue
Block a user