2 ms·
__attribute__((constructor,used)) This is very clever.. in my CLI I use a dedicated section to build a command table, but the linker script often has to be mo
by jhallenworld 6y ago
__attribute__((constructor,used))
This is very clever.. in my CLI I use a dedicated section to build a command table, but the linker script often has to be modified for this to work. The above avoids the need to change the linker script at all (but you do need an init function, which I don't..). It means you have to compile as C++, right?
- lunixbochs 6y agoconstructor works fine in C as with GCC/clang. It links down to .init/.init_array on ELF (though all the linker cares about is PT_DYNAMIC and DT_INIT / DT_INIT_ARRAY)