9 ms·
The linker script is what runs the global constructors in C++. Nothing preventing using a custom linker script in C to call some `premain()` function.
by jononor 9y ago
The linker script is what runs the global constructors in C++. Nothing preventing using a custom linker script in C to call some `premain()` function.
- baruch 9y agoAt least in gcc you can use constructor attribute to run code before main. I've seen this used to initialize modules and create a dependency tree of modules to initialize before main even starts.
- housel 9y agoTo be picky, the linker script lays out a sequence of calls to the global constructors so that the C runtime startup knows where to find and execute them.