[ELF] Postpone ASSERT error

assignAddresses is executed more than once. When an ASSERT expression
evaluates to zero, we should only report an error for the last
assignAddresses. Make a change similar to #66854 and #96361.

This change might help https://github.com/ClangBuiltLinux/linux/issues/2094
This commit is contained in:
Fangrui Song
2025-05-28 20:56:13 -07:00
parent 332fe08f1d
commit 5859863bab
2 changed files with 6 additions and 5 deletions

View File

@@ -900,9 +900,9 @@ Expr ScriptParser::readAssert() {
StringRef msg = readName();
expect(")");
return [=, s = ctx.script, &ctx = ctx]() -> ExprValue {
return [=, s = ctx.script]() -> ExprValue {
if (!e().getValue())
Err(ctx) << msg;
s->recordError(msg);
return s->getDot();
};
}