[PATCH] D16924: [ELF] - Linker script expressions, ASSERT() command.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 07:05:16 PST 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.

This patch implements linker script expressions and also ASSERT() command (is used to check the results for this patch).
Currently I think all possible operands are supported:  ^, *, /, +, -, <<, >>, &, |, (, ), +=, -=, *=, /=, <<=, >>=, &=, |=.

This gives ability to assign values to variables and perform different calculations. 
Sample of what is possible to do (test.script):
```
x = 1 + 2 * 3 - (4 - 5) ^ 1;
y = x << 2 & x | 15;
z = (((x + y) - x) + y) * 2;
x <<= (y + z / y);
x >>= (16 & 17);
x &= 0x7F;
x /= (0x1278 - 4696);
c = 1 >> 1;
ASSERT(x - c, "Custom error text");
```
This will error out "Custom error text" as "x-c" expression gives 0 after evaluation here.
Test cases for all operations are provided.

http://reviews.llvm.org/D16924

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript-expressions.s
  test/ELF/linkerscript.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16924.47015.patch
Type: text/x-patch
Size: 19019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160205/d52b6afa/attachment.bin>


More information about the llvm-commits mailing list