We now always create the fragment, which lets us handle things like .org after
a .align.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252101
91177308-0d34-0410-b5e6-
96231b3b80d8
case MCFragment::FT_Org: {
const MCOrgFragment &OF = cast<MCOrgFragment>(F);
- int64_t TargetLocation;
- if (!OF.getOffset().evaluateAsAbsolute(TargetLocation, Layout))
+ MCValue Value;
+ if (!OF.getOffset().evaluateAsValue(Value, Layout))
report_fatal_error("expected assembly-time absolute expression");
// FIXME: We need a way to communicate this error.
uint64_t FragmentOffset = Layout.getFragmentOffset(&OF);
+ int64_t TargetLocation = Value.getConstant();
+ if (const MCSymbolRefExpr *A = Value.getSymA()) {
+ uint64_t Val;
+ if (!Layout.getSymbolOffset(A->getSymbol(), Val))
+ report_fatal_error("expected absolute expression");
+ TargetLocation += Val;
+ }
int64_t Size = TargetLocation - FragmentOffset;
if (Size < 0 || Size >= 0x40000000)
report_fatal_error("invalid .org offset '" + Twine(TargetLocation) +
bool MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset,
unsigned char Value) {
- int64_t Res;
- if (Offset->evaluateAsAbsolute(Res, getAssembler())) {
- insert(new MCOrgFragment(*Offset, Value));
- return false;
- }
-
- 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()))
- return true;
- EmitFill(Res, Value);
+ insert(new MCOrgFragment(*Offset, Value));
return false;
}
.extern foo
-# CHECK: error: expected absolute expression
+# CHECK: : expected absolute expression
. = foo + 10
.byte 1
three:
.quad 0xdddddddddddddddd
+ .align 4
+ . = three + 9
+
// CHECK: Section {
// CHECK: Name: .text
// CHECK-NEXT: Type:
// CHECK: SectionData (
// CHECK-NEXT: 0000: FFFFFFFF FFFFFFFF 00000000 00000000
// CHECK-NEXT: 0010: 00000000 00000000 EEEEEEEE EEEEEEEE
-// CHECK-NEXT: 0020: DDDDDDDD DDDDDDDD
+// CHECK-NEXT: 0020: DDDDDDDD DDDDDDDD 00 |
// CHECK-NEXT: )