4 ms·
The article is conflating two things: * What happens before main() * What can you do to make code run before main() It suggests only the avenue of C++ global
by jcranmer 9y ago
The article is conflating two things:
* What happens before main()
* What can you do to make code run before main()
It suggests only the avenue of C++ global constructors to make code run before main() (as others have noted, __attribute__((constructor)) is basically the same thing for C). But there are other ways to make code run before main, such as by use of linker scripts and assembly files to put code in _start that eventually calls main() (note that it's this latter way by which all of the things they mention are done).