File tree Expand file tree Collapse file tree 4 files changed +15
-20
lines changed Expand file tree Collapse file tree 4 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -1911,13 +1911,7 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
1911
1911
hasInput = true ;
1912
1912
break ;
1913
1913
case OPT_defsym: {
1914
- StringRef from;
1915
- StringRef to;
1916
- std::tie (from, to) = StringRef (arg->getValue ()).split (' =' );
1917
- if (from.empty () || to.empty ())
1918
- error (" --defsym: syntax error: " + StringRef (arg->getValue ()));
1919
- else
1920
- readDefsym (from, MemoryBufferRef (to, " --defsym" ));
1914
+ readDefsym (MemoryBufferRef (arg->getValue (), " --defsym" ));
1921
1915
break ;
1922
1916
}
1923
1917
case OPT_script:
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class ScriptParser final : ScriptLexer {
53
53
void readLinkerScript ();
54
54
void readVersionScript ();
55
55
void readDynamicList ();
56
- void readDefsym (StringRef name );
56
+ void readDefsym ();
57
57
58
58
private:
59
59
void addFile (StringRef path);
@@ -283,9 +283,12 @@ void ScriptParser::readLinkerScript() {
283
283
}
284
284
}
285
285
286
- void ScriptParser::readDefsym (StringRef name ) {
286
+ void ScriptParser::readDefsym () {
287
287
if (errorCount ())
288
288
return ;
289
+ inExpr = true ;
290
+ StringRef name = readName ();
291
+ expect (" =" );
289
292
Expr e = readExpr ();
290
293
if (!atEOF ())
291
294
setError (" EOF expected, but got " + next ());
@@ -1854,7 +1857,4 @@ void elf::readDynamicList(MemoryBufferRef mb) {
1854
1857
ScriptParser (mb).readDynamicList ();
1855
1858
}
1856
1859
1857
- void elf::readDefsym (StringRef name, MemoryBufferRef mb) {
1858
- llvm::TimeTraceScope timeScope (" Read defsym input" , name);
1859
- ScriptParser (mb).readDefsym (name);
1860
- }
1860
+ void elf::readDefsym (MemoryBufferRef mb) { ScriptParser (mb).readDefsym (); }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ void readVersionScript(MemoryBufferRef mb);
24
24
void readDynamicList (MemoryBufferRef mb);
25
25
26
26
// Parses the defsym expression.
27
- void readDefsym (StringRef name, MemoryBufferRef mb);
27
+ void readDefsym (MemoryBufferRef mb);
28
28
29
29
bool hasWildcard (StringRef s);
30
30
Original file line number Diff line number Diff line change 5
5
# RUN: llvm-objdump -d --print-imm-hex %t | FileCheck %s --check-prefix=USE
6
6
7
7
## Check that we accept --defsym foo2=foo1 form.
8
- # RUN: ld.lld -o %t2 %t.o --defsym foo2=foo1
8
+ # RUN: ld.lld -o %t2 %t.o --defsym '" foo2" =foo1'
9
9
# RUN: llvm-readelf -s %t2 | FileCheck %s
10
10
# RUN: llvm-objdump -d --print-imm-hex %t2 | FileCheck %s --check-prefix=USE
11
11
12
12
## Check we are reporting the error correctly and don't crash
13
13
## when handling the second --defsym.
14
- # RUN: not ld.lld -o /dev/null %t.o --defsym ERR+ --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR
15
- # ERR: error: --defsym: syntax error: ERR+
14
+ # RUN: not ld.lld -o /dev/null %t.o --defsym ERR+ --defsym foo2=foo1 2>&1 | FileCheck %s --check-prefix=ERR --strict-whitespace
15
+ # ERR:error: --defsym:1: = expected, but got +
16
+ # ERR-NEXT:>>> ERR+
17
+ # ERR-NEXT:>>> ^
16
18
17
19
# CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo1
18
20
# CHECK-DAG: 0000000000000123 0 NOTYPE GLOBAL DEFAULT ABS foo2
41
43
# ERR2: error: --defsym:1: EOF expected, but got ,
42
44
43
45
# RUN: not ld.lld -o /dev/null %t.o --defsym=foo 2>&1 | FileCheck %s -check-prefix=ERR3
44
- # ERR3: error: --defsym: syntax error: foo
46
+ # ERR3: error: --defsym:1: unexpected EOF
45
47
46
- # RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR4
47
- # ERR4: error: --defsym: syntax error:
48
+ # RUN: not ld.lld -o /dev/null %t.o --defsym= 2>&1 | FileCheck %s -check-prefix=ERR3
48
49
49
50
.globl foo1
50
51
foo1 = 0x123
You can’t perform that action at this time.
0 commit comments