rust-abi-wiki icon indicating copy to clipboard operation
rust-abi-wiki copied to clipboard

Could loading a Rust dynamic library requires a (very up-to-date) special linker?

Open robinmoussu opened this issue 3 years ago • 8 comments

When loading a dynamic library, the dynamic linker does some basics things like defining the address of the relocatable code, … For C and C++ those mechanisms are very basics, and standardized since a long time. This allow basically any library compiled with any compiler to be dynamically linked using any dynamic linker, without any regards to the versions of the various tools used.

If we could require a special linker for dynamically linking rust binaries, this would allow to apply custom logic during loading time. Requiring a (very) up-to-date Rust dynamic linker would also allow to change the ABI specification since the new linker would know what to do with it. However, this means that in order to start any binary using a Rust dynamic library, the user would need to have a compatible (ie. up-to-date) dynamic Rust linker.

I see 3 options:

  • restrict ourself to the current capabilities of the current linkers.
  • create a new linker, with added capabilities, then fix that new capability set in stone (so it would be possible to dynamically link a Rust library compiled in 2030 with a 2021 Rust dynamic linker).
  • create a new linker, with added capabilities, and allow ourself to modify the set of capabilities in the future (for example for each Rust edition) which requires the user to update each time (ie. every 3 years with the current release cycle of Rust editions).

robinmoussu avatar Oct 28 '20 11:10 robinmoussu