lib: Inline igt_x86_features() into ifunc resolvers
Quoting https://sourceware.org/glibc/wiki/GNU_IFUNC > When LD_BIND_NOW=1 or -Wl,z,now is in effect symbols must be > immediately resolved at startup. In cases where an external function > call depends needs to be made that may fail if such a call has not > been initialized yet (PLT-based relocation which is processed later). > For example calling strlen in an IFUNC resolver built with -Wl,z,now > may lead to a segfault because the PLT is not yet resolved. We cannot rely on function calls through the PLT in ifunc resolvers as the PLT may not have been initialized yet. In practice, this causes crashes when igt is linked with -Wl,-z,now or when linked with the mold linker. To avoid this problem, we do two things: 1. move igt_x86_features() to igt_x86.h so its definition is available to compilation units that call the function. 2. mark the ifunc resolvers with __attribute__((flatten)) to ensure igt_x86_features() is inlined. Since this function is only called from a few places it does not significantly increase binary size to inline it. Linux distros (at least Fedora since v23, Gentoo/Hardened, soon standard Gentoo) use `-Wl,-z now` to improve security. By binding upfront, the loader can mark the GOT as read-only for a security enhancement. See https://wiki.gentoo.org/wiki/Hardened/Toolchain for more details. [Fixed whitespaces (Kamil)] Bug: https://bugs.gentoo.org/788625 Bug: https://bugs.gentoo.org/925348 Reviewed-by:Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by:
Matt Turner <mattst88@gmail.com>
Loading
-
mentioned in issue #102 (closed)
-
mentioned in issue #127 (closed)
Please register or sign in to comment