This small patch adds the support for ! operator in linker scripts.
Details
Diff Detail
Event Timeline
| test/ELF/linkerscript/assert.s | ||
|---|---|---|
| 46 ↗ | (On Diff #110150) | I tried but it was not immediately obvious how to do it. |
| test/ELF/linkerscript/symbol-assignexpr.s | ||
| 18 | The linker script parsing have problem where it can not separate these operator. You will see that test of ~ operator also use '(' or space in between. I have also changed one test to use space but this needs to be fixed as a separate problem. | |
| test/ELF/linkerscript/assert.s | ||
|---|---|---|
| 46 ↗ | (On Diff #110150) | Following just works, no ? # RUN: echo "SECTIONS { ASSERT(!(1), fail) }" > %t9.script
# RUN: not ld.lld -shared -o %t9 --script %t9.script %t1.o > %t.log 2>&1
# RUN: FileCheck %s -check-prefix=FAIL < %t.log |
| test/ELF/linkerscript/symbol-assignexpr.s | ||
| 18 | I fixed '~' here: D36508, I think you should be able to do the same for '!` | |
| test/ELF/linkerscript/assert.s | ||
|---|---|---|
| 1 ↗ | (On Diff #110337) | I wouldn't add any tests to this file as the feature is tested by symbol-assignexpr.s. |
| 48–52 ↗ | (On Diff #110337) | I wouldn't add this test -- the feature is tested enough with the above two tests. |
| test/ELF/linkerscript/symbol-assignexpr.s | ||
| 18 | Replace !symbol with !1 and add symbol14 = !0. | |
| ELF/ScriptLexer.cpp | ||
|---|---|---|
| 215–217 | I don't think this is correct. For example, I don't think this can handle expression 0!=1. You want to add code to tokenizeExpr instead of this function. | |
| ELF/ScriptLexer.cpp | ||
|---|---|---|
| 215–217 | I think 0!=1 was failing even without my patch. I have fixed it now and added a test to check it. | |
LGTM
| ELF/ScriptLexer.cpp | ||
|---|---|---|
| 195–199 | This is probably a bit more straightforward: if (S.substr(E).startswith("!=")) {
Ret.push_back(S.substr(E, 2));
S = S.substr(E + 2);
} else {
Ret.push_back(S.substr(E, 1));
S = S.substr(E + 1);
} | |
| test/ELF/linkerscript/symbol-assignexpr.s | ||
| 20 | Thank you for adding this test. | |
This is probably a bit more straightforward:
if (S.substr(E).startswith("!=")) { Ret.push_back(S.substr(E, 2)); S = S.substr(E + 2); } else { Ret.push_back(S.substr(E, 1)); S = S.substr(E + 1); }