[PATCH] D36508: [ELF] - Linkerscript: Add `~` as separate math token.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 03:59:28 PDT 2017


grimar created this revision.
Herald added a subscriber: emaste.

Previously we did not support following:
`foo = ~0xFF;`
and had to add space before numeric value:
`foo = ~ 0xFF`

That was constistent with ld.bfd, which shows:
script.txt:3: undefined symbol `~2' referenced in expression,
but inconsistent with gold and generally seems not convinent.

I suggest to be consistent with gold's behavior here.


https://reviews.llvm.org/D36508

Files:
  ELF/ScriptLexer.cpp
  test/ELF/linkerscript/symbol-assignexpr.s


Index: test/ELF/linkerscript/symbol-assignexpr.s
===================================================================
--- test/ELF/linkerscript/symbol-assignexpr.s
+++ test/ELF/linkerscript/symbol-assignexpr.s
@@ -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; \
Index: ELF/ScriptLexer.cpp
===================================================================
--- ELF/ScriptLexer.cpp
+++ ELF/ScriptLexer.cpp
@@ -168,7 +168,7 @@
 // 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("\""))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36508.110345.patch
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170809/7a285ab0/attachment-0001.bin>


More information about the llvm-commits mailing list