diff options
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/defsym.s | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 6aed439cf4f..008439f97b4 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -271,6 +271,8 @@ void ScriptParser::readLinkerScript() { } void ScriptParser::readDefsym(StringRef Name) { + if (errorCount()) + return; Expr E = readExpr(); if (!atEOF()) setError("EOF expected, but got " + next()); diff --git a/lld/test/ELF/defsym.s b/lld/test/ELF/defsym.s index 1bf5064ae0e..598ecd51681 100644 --- a/lld/test/ELF/defsym.s +++ b/lld/test/ELF/defsym.s @@ -9,6 +9,12 @@ # RUN: llvm-readobj -t -s %t2 | FileCheck %s # RUN: llvm-objdump -d -print-imm-hex %t2 | FileCheck %s --check-prefix=USE +## Check we are reporting the error correctly and don't crash +## when handling the second --defsym. +# RUN: not ld.lld -o %t2 %t.o --defsym ERR+ \ +# --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR +# ERR: error: -defsym: syntax error: ERR+ + # CHECK: Symbol { # CHECK: Name: foo1 # CHECK-NEXT: Value: 0x123 |