[llvm] r231295 - Expand variables when evaluating absolute expressions.
Rafael Espindola
rafael.espindola at gmail.com
Wed Mar 4 14:03:21 PST 2015
Author: rafael
Date: Wed Mar 4 16:03:21 2015
New Revision: 231295
URL: http://llvm.org/viewvc/llvm-project?rev=231295&view=rev
Log:
Expand variables when evaluating absolute expressions.
This allows for variables to be used in .size.
This matches gnu AS functionality.
Added:
llvm/trunk/test/MC/ELF/size.s
Modified:
llvm/trunk/lib/MC/MCExpr.cpp
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=231295&r1=231294&r2=231295&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Wed Mar 4 16:03:21 2015
@@ -436,7 +436,7 @@ bool MCExpr::evaluateAsAbsolute(int64_t
}
bool IsRelocatable = EvaluateAsRelocatableImpl(
- Value, Asm, Layout, nullptr, Addrs, InSet, /*ForceVarExpansion*/ false);
+ Value, Asm, Layout, nullptr, Addrs, InSet, /*ForceVarExpansion*/ true);
// Record the current value.
Res = Value.getConstant();
Added: llvm/trunk/test/MC/ELF/size.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/size.s?rev=231295&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/size.s (added)
+++ llvm/trunk/test/MC/ELF/size.s Wed Mar 4 16:03:21 2015
@@ -0,0 +1,15 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux < %s | llvm-readobj -t | FileCheck %s
+
+foo:
+bar = .
+ .size foo, . - bar + 42
+
+// CHECK: Symbol {
+// CHECK: Name: foo
+// CHECK-NEXT: Value: 0x0
+// CHECK-NEXT: Size: 42
+// CHECK-NEXT: Binding: Local
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: .text
+// CHECK-NEXT: }
More information about the llvm-commits
mailing list