Skip to content

Commit

Permalink
[ELF] Replace error() with errorOrWarn() for the ASSERT command
Browse files Browse the repository at this point in the history
Summary:
ld.bfd produces an output with --noinhibit-exec when an ASSERT fails.
Use errorOrWarn() so that we can produce an output as well.

An interesting case is that symbol assignments may execute multiple
times, so we probably want to suppress errors for non-final runs.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D67285

llvm-svn: 371225
  • Loading branch information
MaskRay committed Sep 6, 2019
1 parent 52614df commit 2682bc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/ScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ Expr ScriptParser::readAssert() {

return [=] {
if (!e().getValue())
error(msg);
errorOrWarn(msg);
return script->getDot();
};
}
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/linkerscript/assert.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# RUN: llvm-readobj %t1 > /dev/null

# RUN: echo "SECTIONS { ASSERT(0, fail) }" > %t3.script
# RUN: not ld.lld -shared -o /dev/null --script %t3.script %t1.o > %t.log 2>&1
# RUN: FileCheck %s -check-prefix=FAIL < %t.log
# RUN: not ld.lld -o /dev/null -T %t3.script %t1.o 2>&1 | FileCheck --check-prefix=FAIL %s
# RUN: ld.lld -o /dev/null -T %t3.script %t1.o --noinhibit-exec 2>&1 | FileCheck --check-prefix=FAIL %s
# FAIL: fail

# RUN: echo "SECTIONS { . = ASSERT(0x1000, fail); }" > %t4.script
Expand Down

0 comments on commit 2682bc3

Please sign in to comment.