I'm reading this article: https://ypl.coffee/dl-resolve/
Since the GOT table is resolved at runtime (at first call to this function), I'm wondering how does _dl_runtime_resolve ensure it's multi-thread safe?
I'm reading this article: https://ypl.coffee/dl-resolve/
Since the GOT table is resolved at runtime (at first call to this function), I'm wondering how does _dl_runtime_resolve ensure it's multi-thread safe?
how does
_dl_runtime_resolveensure it's multi-thread safe?
Any pure function is thread-safe by definition.
_dl_runtime_resolve is not pure (updates the GOT slot), but if two threads are resolving the same symbol in parallel, both threads will resolve to the same symbol (i.e. they'll compute the exact same target address), and will write the same value into the GOT slot.
While technically this is a data race, practically it doesn't lead to any observable problems.