diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-09-20 18:56:08 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-09-20 18:56:08 +0000 |
commit | 01a409520b39946bd4c7e86f83bc2d01d8c839d4 (patch) | |
tree | 32124fbd3fd908e7a83578cd2773040e7d7c4d0d | |
parent | be46b4e6d72a2689e59b6286d245c95a31b3a901 (diff) | |
download | bcm5719-llvm-01a409520b39946bd4c7e86f83bc2d01d8c839d4.tar.gz bcm5719-llvm-01a409520b39946bd4c7e86f83bc2d01d8c839d4.zip |
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".
llvm-svn: 313794
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript/early-assign-symbol.s | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 7d01bac1f39..e91825680a5 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -139,7 +139,7 @@ static bool isUnderSysroot(StringRef Path) { // 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"); diff --git a/lld/test/ELF/linkerscript/early-assign-symbol.s b/lld/test/ELF/linkerscript/early-assign-symbol.s index 413724e113d..5f611786366 100644 --- a/lld/test/ELF/linkerscript/early-assign-symbol.s +++ b/lld/test/ELF/linkerscript/early-assign-symbol.s @@ -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 |