[lld] r313794 - Consider only A.Sec in moveAbsRight.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 11:56:08 PDT 2017
Author: rafael
Date: Wed Sep 20 11:56:08 2017
New Revision: 313794
URL: http://llvm.org/viewvc/llvm-project?rev=313794&view=rev
Log:
Consider only A.Sec in moveAbsRight.
The idea of this function is to simplify the implementation of binary
operators like add.
A value might be absolute because of an ABSOLUTE expression, but it
still depends on the value of a section and we might not be able to
evaluate it early. We should keep such values on the LHS, so that we
can delay the evaluation.
We can now handle both "1 + ABSOLUTE(foo)" and "ABSOLUTE(foo) + 1".
Modified:
lld/trunk/ELF/ScriptParser.cpp
lld/trunk/test/ELF/linkerscript/early-assign-symbol.s
Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=313794&r1=313793&r2=313794&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Wed Sep 20 11:56:08 2017
@@ -139,7 +139,7 @@ static bool isUnderSysroot(StringRef Pat
// Some operations only support one non absolute value. Move the
// absolute one to the right hand side for convenience.
static void moveAbsRight(ExprValue &A, ExprValue &B) {
- if (A.isAbsolute())
+ if (A.Sec == nullptr)
std::swap(A, B);
if (!B.isAbsolute())
error(A.Loc + ": at least one side of the expression must be absolute");
Modified: lld/trunk/test/ELF/linkerscript/early-assign-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/early-assign-symbol.s?rev=313794&r1=313793&r2=313794&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/early-assign-symbol.s (original)
+++ lld/trunk/test/ELF/linkerscript/early-assign-symbol.s Wed Sep 20 11:56:08 2017
@@ -1,9 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t2.script
-# RUN: not ld.lld -o %t --script %t2.script %t.o 2>&1 | FileCheck %s
-
# RUN: echo "SECTIONS { aaa = foo | 1; .text : { *(.text*) } }" > %t3.script
# RUN: not ld.lld -o %t --script %t3.script %t.o 2>&1 | FileCheck %s
@@ -11,6 +8,10 @@
# Simple cases that we can handle.
+# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+# RUN: llvm-objdump -t %t | FileCheck --check-prefix=VAL %s
+
# RUN: echo "SECTIONS { aaa = 1 + ABSOLUTE(foo - 1); .text : { *(.text*) } }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
# RUN: llvm-objdump -t %t | FileCheck --check-prefix=VAL %s
More information about the llvm-commits
mailing list