forked from OSchip/llvm-project
[ELF] - Make ASSERT() return Dot instead of evaluated value.
Previously ASSERT we implemented returned expression value. Ex: . = ASSERT(0x100); would set Dot value to 0x100 Form of assert when it is assigned to Dot was implemented for compatibility with very old GNU ld which required it. Some scripts in the wild, including linux kernel scripts use such ASSERTs at the end for doing different checks. Currently we fail with "unable to move location counter backward" for such scripts. Patch changes ASSERT to return location counter value to fix that. Differential revision: https://reviews.llvm.org/D30171 llvm-svn: 295703
This commit is contained in:
parent
002549b8be
commit
60f1fe8438
|
@ -1468,10 +1468,9 @@ Expr ScriptParser::readAssert() {
|
|||
StringRef Msg = unquote(next());
|
||||
expect(")");
|
||||
return [=](uint64_t Dot) {
|
||||
uint64_t V = E(Dot);
|
||||
if (!V)
|
||||
if (!E(Dot))
|
||||
error(Msg);
|
||||
return V;
|
||||
return Dot;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
# RUN: ld.lld -shared -o %t1 --script %t1.script %t1.o
|
||||
# RUN: llvm-readobj %t1 > /dev/null
|
||||
|
||||
# RUN: echo "SECTIONS { ASSERT(ASSERT(42, fail) == 42, fail) }" > %t2.script
|
||||
# RUN: ld.lld -shared -o %t2 --script %t2.script %t1.o
|
||||
# RUN: llvm-readobj %t2 > /dev/null
|
||||
|
||||
# RUN: echo "SECTIONS { ASSERT(0, fail) }" > %t3.script
|
||||
# RUN: not ld.lld -shared -o %t3 --script %t3.script %t1.o > %t.log 2>&1
|
||||
# RUN: FileCheck %s -check-prefix=FAIL < %t.log
|
||||
|
|
|
@ -3,3 +3,6 @@
|
|||
# RUN: echo "SECTIONS { . = 0x20; . = 0x10; }" > %t.script
|
||||
# RUN: not ld.lld %t.o --script %t.script -o %t -shared 2>&1 | FileCheck %s
|
||||
# CHECK: unable to move location counter backward
|
||||
|
||||
# RUN: echo "SECTIONS { . = 0x20; . = ASSERT(0x1, "foo"); }" > %t2.script
|
||||
# RUN: ld.lld %t.o --script %t2.script -o %t -shared
|
||||
|
|
Loading…
Reference in New Issue