2026-04-16 19:23 UTC
Replies (2)
-
@pinskia@hachyderm.io 2026-04-16 19:36
@bal4e @folkertdev GNU ifuncs (it depends on glibc, special relocations in the elf file too) is not weirdly implemented if you understand how PLT and elf (dynamic) shared library PIC code works. Basically all calls in a shared library is done via a PLT (and to a shared library from the main application). This is normally lazy binding too (but that does not matter here really). Each PLT has a location which stores the function pointer at runtime. At load time the PLT location is set to loader location. And then that loader location call will resolve the function to the right location and store it back. For ifuncs instead of just doing a lookup of the symbol; it does that lookup and then calls that "resolver" function which returns another function. That new function is what is called/stored into the PLT location. (non-lazying bindings work very similar except instead of a loader function be set to the PLT location, the resolver function is called at load time rather than lazy).
-
@folkertdev@hachyderm.io 2026-04-16 20:17
@bal4e ah, right, that totally works. e.g. https://crates.io/crates/multiversion So we'd want something like this conceptually, but in std/the compiler. We're not using this in zlib-rs in part because it did not seem to matter that much versus just a well-predicted branch but mostly because of the additional unsafety.