Skip to content

Commit 21bf6bb

Browse files
committed
[ELF] Fix assertion failure when PROVIDE/HIDDEN/PROVIDE_HIDDEN does not have =
1 parent fe0de25 commit 21bf6bb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,14 @@ std::array<uint8_t, 4> ScriptParser::readFill() {
10171017

10181018
SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) {
10191019
expect("(");
1020-
SymbolAssignment *cmd = readSymbolAssignment(next());
1020+
StringRef name = next(), eq = peek();
1021+
if (eq != "=") {
1022+
setError("= expected, but got " + next());
1023+
while (!atEOF() && next() != ")")
1024+
;
1025+
return nullptr;
1026+
}
1027+
SymbolAssignment *cmd = readSymbolAssignment(name);
10211028
cmd->provide = provide;
10221029
cmd->hidden = hidden;
10231030
expect(")");

lld/test/ELF/linkerscript/symbols.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
# SIMPLE2: 0000000000000100 g *ABS* 0000000000000000 bar
7474
# SIMPLE2: 0000000000000100 g *ABS* 0000000000000000 baz
7575

76+
# RUN: echo 'PROVIDE(somesym + 1);' > %t.script
77+
# RUN: not ld.lld -T %t.script %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=PROVIDE-ERR
78+
79+
# PROVIDE-ERR: {{.*}}:1: = expected, but got +
80+
7681
.global _start
7782
_start:
7883
nop

0 commit comments

Comments
 (0)