[llvm-commits] [llvm] r126091 - in /llvm/trunk: lib/MC/MCObjectStreamer.cpp test/MC/ELF/org.s
Rafael Espindola
rafael.espindola at gmail.com
Sun Feb 20 12:20:07 PST 2011
Author: rafael
Date: Sun Feb 20 14:20:07 2011
New Revision: 126091
URL: http://llvm.org/viewvc/llvm-project?rev=126091&view=rev
Log:
Add some limited support for labels in org directives. Hopefully enough to fix
PR9245.
Added:
llvm/trunk/test/MC/ELF/org.s
Modified:
llvm/trunk/lib/MC/MCObjectStreamer.cpp
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=126091&r1=126090&r2=126091&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Sun Feb 20 14:20:07 2011
@@ -242,7 +242,23 @@
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() {
Added: llvm/trunk/test/MC/ELF/org.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/org.s?rev=126091&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/org.s (added)
+++ llvm/trunk/test/MC/ELF/org.s Sun Feb 20 14:20:07 2011
@@ -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)
More information about the llvm-commits
mailing list