I am building a library which roughly boils down to this:
// foo.c
extern void func();
int main() {
// ...
}
I compile with gcc -o foo func.o foo.c
.
This results in a binary where the symbol func
is before main
(i.e. has lower address).
However if I add optimization, f.e. -O3
the linker decides to place func
after main
.
Is there a way to enforce this order?