Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
elf: ignore versioning table if symbol is looked up by object itself
The commit ed1eed7 enhanced dynamic linker to skip old symbols per versions table. Unfortunately the relevant code did not take into account whether the old symbol is being looked up by the object itself during relocation. This sentence from https://www.akkadia.org/drepper/symbol-versioning - "If the highest bit (bit 15) is set this is a hidden symbol which cannot be referenced from outside the object." - SEEMS to indicate the old symbols should be visible to the object itself only. This patch enhances lookup method to help track "who" is looking and if it is the object itself, then the versions table is ignored. Here is some background information: The main (and so far the only one) motivation for this patch is to allow upgrading libgcc_s.so to the newest version from host instead of relying on the "antique" version from externals (see usr.manifest.skel). It turns out that at some point (starting with version 6) GCC team moved the __cpu_model and __cpu_indicator_init (constructor function) symbols from the shared library libgcc_s.so to the static one - libgcc.a (please see this commit for some details - gcc-mirror/gcc@4b5fb32#diff-3592c95126806aad11bb0f09e182f2f4) and marked them as "compat" in libgcc_s.so (shown with single @). This makes those symbols invisible to OSv linker because per symbols version table they are effectively "old" and should be ignored during lookup but not to the object itself when it tries to relocate them. This patch actually makes the change to the version symbol handling logic to achieve exactly that. The version symbol handling logic in OSv is based on musl, but musl does not try to expose such "old" symbols to the object itself like this patch does. It turns out that Musl team complained about original change to libgcc_s.so and GCC team changed how libgcc_s.so for musl is built. This commit - gcc-mirror/gcc@6e6c7fc and this discussion - https://patchwork.ozlabs.org/patch/693782/ - sheds some light. Signed-off-by: Waldemar Kozaczuk <[email protected]>
- Loading branch information