[lld] 21bf6bb - [ELF] Fix assertion failure when PROVIDE/HIDDEN/PROVIDE_HIDDEN does not have =
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 25 20:26:52 PDT 2022
Author: Fangrui Song
Date: 2022-06-25T20:26:47-07:00
New Revision: 21bf6bb3d369e5de70b65ad3a9e1149070e3a7cd
URL: https://github.com/llvm/llvm-project/commit/21bf6bb3d369e5de70b65ad3a9e1149070e3a7cd
DIFF: https://github.com/llvm/llvm-project/commit/21bf6bb3d369e5de70b65ad3a9e1149070e3a7cd.diff
LOG: [ELF] Fix assertion failure when PROVIDE/HIDDEN/PROVIDE_HIDDEN does not have =
Added:
Modified:
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/symbols.s
Removed:
################################################################################
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index d0fa449f5823..1f0600572bda 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1017,7 +1017,14 @@ std::array<uint8_t, 4> ScriptParser::readFill() {
SymbolAssignment *ScriptParser::readProvideHidden(bool provide, bool hidden) {
expect("(");
- SymbolAssignment *cmd = readSymbolAssignment(next());
+ StringRef name = next(), eq = peek();
+ if (eq != "=") {
+ setError("= expected, but got " + next());
+ while (!atEOF() && next() != ")")
+ ;
+ return nullptr;
+ }
+ SymbolAssignment *cmd = readSymbolAssignment(name);
cmd->provide = provide;
cmd->hidden = hidden;
expect(")");
diff --git a/lld/test/ELF/linkerscript/symbols.s b/lld/test/ELF/linkerscript/symbols.s
index d5c3c2255411..1e6da7b92eff 100644
--- a/lld/test/ELF/linkerscript/symbols.s
+++ b/lld/test/ELF/linkerscript/symbols.s
@@ -73,6 +73,11 @@
# SIMPLE2: 0000000000000100 g *ABS* 0000000000000000 bar
# SIMPLE2: 0000000000000100 g *ABS* 0000000000000000 baz
+# RUN: echo 'PROVIDE(somesym + 1);' > %t.script
+# RUN: not ld.lld -T %t.script %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=PROVIDE-ERR
+
+# PROVIDE-ERR: {{.*}}:1: = expected, but got +
+
.global _start
_start:
nop
More information about the llvm-commits
mailing list