3 ms·
The assembler laid out the code within the sections and generally it's not changed after that (except for targets that do linker relaxation). However with -ffun
by wyldfire 4y ago
The assembler laid out the code within the sections and generally it's not changed after that (except for targets that do linker relaxation). However with -ffunction-sections the compiler would put each function in its own section which then can be independently relocated.
- KMag 4y agoIf each function is in its own section, then all function calls would need to be indirected through the PLT/GOT, even function calls within the same translation unit? Ouch.
- wyldfire 4y agoNo - the linker is there to resolve references among sections and can do so without PLT/GOT indirection when creating things like static archives. There may be a code size cost in some architectures - that since the call destination can be relocated far from the call site that the assembler will need to make sure it allocates enough space to reach the call target instead of a small PCREL relocation.