|
|
Subscribe / Log in / New account

A look at dynamic linking

A look at dynamic linking

Posted Feb 13, 2024 16:04 UTC (Tue) by abatters (✭ supporter ✭, #6932)
Parent article: A look at dynamic linking

Does the linker handle indirect functions?

https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Common-Func...


to post comments

A look at dynamic linking

Posted Feb 14, 2024 12:50 UTC (Wed) by nix (subscriber, #2304) [Link] (2 responses)

This too is largely the dynamic linker's job, yes: the linker proper just translates the ifuncs GCC emits into STT_GNU_IFUNC-type symbols in the final ELF object.

As an aside, there are fairly harsh restrictions on what ifuncs can do -- notably, since they're called in the middle of dynamic symbol resolution, they can't call anything else which might go through the dynamic linker, which more or less means static functions only.

A look at dynamic linking

Posted Feb 17, 2024 8:33 UTC (Sat) by fw (subscriber, #26023) [Link] (1 responses)

Some targets require relocation processing for static functions and global data access, too. The way that this is supposed to work is that objects make their dependencies explicit using DT_NEEDED. This way, the dynamic linker can compute a relocation order that processes the object containing the IFUNC before the object that invokes.

In practice, this does not always work with symbol interposition, which is not refected in the DT_NEEDED dependencies:

A look at dynamic linking

Posted Feb 21, 2024 12:19 UTC (Wed) by nix (subscriber, #2304) [Link]

Ah, thanks for that: I was sure there were awful dependency-related subtleties involved but had entirely forgotten what they were! (IIRC that in the early days IFUNCs were just executed whenever, with no particular guarantees about what if anything else had been relocated. Surprisingly, even this was enough to do a lot of useful things with them.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds