3 ms·
Very useful article! I wish I had read this a long time ago, would've made a lot of things much easier to understand. I'd like to comment on this: > When the
by matheusmoreira 4y ago
Very useful article! I wish I had read this a long time ago, would've made a lot of things much easier to understand.
I'd like to comment on this:
> When the relocations are complete, the dynamic linker allows any loaded shared object to execute optional initialization code. This functionality allows the library to initialize internal data and prepare for use.
> This code is defined in the .init section of the ELF image. When the library is unloaded, it may also call a termination function (defined as the .fini section in the image).
There are huge problems with this stuff. Are these sections still used? I know you can add functions to these sections with a GCC attribute but I don't know why anyone would do that. Do other languages like C++ use these sections?
https://blogs.oracle.com/solaris/post/init-and-fini-processing-who-designed-this https://blogs.oracle.com/solaris/post/init-and-fini-processi...
- monocasa 4y agoYes they're still used. C++ heavily uses them as you've guessed. Off the top of my head QEMU also uses them as a way to register all the machine variants it supports internally without having big per arch tables in source that everyone needs to constantly have merge conflicts with.
- cryptonector 4y agoThe Solaris Linker Guide is still the best document written on ELF and dynamic linking. I highly recommend spending some time with it.
- akshaykumar90 4y agoCan you share a link if available?
- cryptonector 4y agohttps://docs.oracle.com/cd/E53394_01/html/E54813/index.html https://docs.oracle.com/cd/E53394_01/html/E54813/index.html
- gnufx 4y agoOutside C++, for instance, constructor functions are useful in LD_PRELOAD objects to fix up things before a binary's entry point runs.