News for hackers. Stuff that matters.
Re:Anatomy of Linux Dynamic Libraries by matheusmoreira on Thursday October 13, 2022 @11:38AM (#33192485)
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-processi...

Re:Anatomy of Linux Dynamic Libraries by monocasa on Thursday October 13, 2022 @11:53AM (#33192713)
Yes 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.
Re:Anatomy of Linux Dynamic Libraries by cryptonector on Thursday October 13, 2022 @12:52PM (#33193569)
The Solaris Linker Guide is still the best document written on ELF and dynamic linking. I highly recommend spending some time with it.
Re:Anatomy of Linux Dynamic Libraries by akshaykumar90 on Thursday October 13, 2022 @01:44PM (#33194225)
Can you share a link if available?
Re:Anatomy of Linux Dynamic Libraries by cryptonector on Thursday October 13, 2022 @03:12PM (#33195198)
Re:Anatomy of Linux Dynamic Libraries by gnufx on Thursday October 13, 2022 @02:07PM (#33194438)
Outside C++, for instance, constructor functions are useful in LD_PRELOAD objects to fix up things before a binary's entry point runs.