A minimal viable example of an assembly program that can be complied with gcc is the following:
.text
.globl main
main:
ret
We compile as follows in x86_64 mode:
$ gcc -o example example.s
In this example, we may include references to "main" or simple pointer arithmetic on "main" as .quad
directives and the linker resolves them properly:
.text
.globl main
main:
ret
.quad main
.quad main + 12345
Gives the expected
0000000000001129 <main>:
1129: c3 ret
112a: 29 11 sub %edx,(%rcx)
[...]
1132: 62 41 (bad)
But how can we include bitwise expressions here? For example:
.quad main | 12345
Results in
Error: invalid operands (.text and *ABS* sections) for `|'
During runtime, this is easy to do, but is there a way to do this in gcc/gas at compile time?