Skip to content

Commit

Permalink
[ELF] - Linkerscript: Add ~ as separate math token.
Browse files Browse the repository at this point in the history
Previously we did not support following:
foo = ~0xFF;
and had to add space before numeric value:
foo = ~ 0xFF

That was constistent with ld.bfd < 2.30, which shows:
script.txt:3: undefined symbol `~2' referenced in expression,
but inconsistent with gold.

It was fixed for ld.bfd 2.30 as well:
https://sourceware.org/bugzilla/show_bug.cgi?id=22267

Differential revision: https://reviews.llvm.org/D36508

llvm-svn: 315569
  • Loading branch information
George Rimar committed Oct 12, 2017
1 parent 3f2b00b commit 81eca18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/ScriptLexer.cpp
Expand Up @@ -164,7 +164,7 @@ bool ScriptLexer::atEOF() { return ErrorCount || Tokens.size() == Pos; }
// Split a given string as an expression.
// This function returns "3", "*" and "5" for "3*5" for example.
static std::vector<StringRef> tokenizeExpr(StringRef S) {
StringRef Ops = "+-*/:!"; // List of operators
StringRef Ops = "+-*/:!~"; // List of operators

// Quoted strings are literal strings, so we don't want to split it.
if (S.startswith("\""))
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/linkerscript/symbol-assignexpr.s
Expand Up @@ -6,7 +6,7 @@
# RUN: symbol2 = symbol + 0x1234; \
# RUN: symbol3 = symbol2; \
# RUN: symbol4 = symbol + -4; \
# RUN: symbol5 = symbol - ~ 0xfffb; \
# RUN: symbol5 = symbol - ~0xfffb; \
# RUN: symbol6 = symbol - ~(0xfff0 + 0xb); \
# RUN: symbol7 = symbol - ~ 0xfffb + 4; \
# RUN: symbol8 = ~ 0xffff + 4; \
Expand Down

0 comments on commit 81eca18

Please sign in to comment.