3 ms·
Linkers are very much like hyperdrives. They're one of those ancient but ubiquitous technologies; no one knows how they work, but no one cares. The basics of d
by jamesdutc 11y ago
Linkers are very much like hyperdrives. They're one of those ancient but ubiquitous technologies; no one knows how they work, but no one cares.
The basics of dynamic linking is actually pretty simple, but it's tricky to find reference materials outside of reading the source code itself. A modern, mature dynamic linker supports a lot of very interesting and very powerful features, from LD_PRELOAD to LD_AUDIT to `dlmopen` (linker namespaces.)
I wonder whether this new linker plans to support all of these advanced features.
I've spent some time with these features to accomplish tasks such as:
- embedding Python interpreters within themselves using `dlmopen` (linker namespaces): https://gist.github.com/dutc/cf808ec7d8e1c36e01cc https://gist.github.com/dutc/cf808ec7d8e1c36e01cc https://gist.github.com/dutc/423d0d0ccba771cf910f https://gist.github.com/dutc/423d0d0ccba771cf910f https://gist.github.com/dutc/eba9b2f7980f400f6287 https://gist.github.com/dutc/eba9b2f7980f400f6287 https://gist.github.com/dutc/2866d969d5e9209d501a https://gist.github.com/dutc/2866d969d5e9209d501a
- writing LD_PRELOAD-like modules in Python:
https://gist.github.com/dutc/6500c804b2f0141c9757 https://gist.github.com/dutc/6500c804b2f0141c9757
I think the LD_AUDIT approach taken by the latter project could also lead to re-implementing a dynamic linker in Python itself via the system's linker's auditing mechanism. This might be a very interesting educational exercise!
- unclesaamm 11y ago> The basics of dynamic linking is actually pretty simple, but it's tricky to find reference materials outside of reading the source code itself. I recommend the dynamic linking chapter in "Linkers & Loaders" by John Levine: http://www.iecc.com/linker/ http://www.iecc.com/linker/
- Aardwolf 11y agoHyperdrives ancient technology? Are you from the future, or from the Star Wars universe? :)
- pacaro 11y agoThis may be a reference to a SciFi trope where a space faring society has use of hyperdrive technology that it bought/stole/inherited from an older civilization, but doesn't have any ability to create and/repair
- rui314 11y agoLD_PRELOAD and LD_AUDIT are the features of the dynamic linker or ld.so. The dynamic linker is a process to read an executable and DSOs in memory, fix up images in memory to make it really ready to be executed by a CPU. lld is a linker which creates executable or DSO files. That is different from the dynamic linker.