[llvm-branch-commits] ELF: Add a -z glibc-228-compat flag for working around an old glibc bug. (PR #133532)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Mar 28 15:33:37 PDT 2025


https://github.com/pcc created https://github.com/llvm/llvm-project/pull/133532

The -z glibc-228-compat flag is intended to be used for
binaries utilizing IFUNCs which need to be compatible with
glibc versions containing a bug that was fixed in commit
b5c45e83753b27dc538dff2d55d4410c385cf3a4 which was released in
version 2.29. The bug causes glibc to mprotect the .text section as
RW while calling ifunc resolvers in binaries linked with -z notext,
leading to a SIGSEGV at startup time. By setting the W flag on the
executable section we work around the bug by avoiding the code path
that does the mprotect. It is recommended that binaries linked with
this flag contain startup code (e.g. in .init_array) that remaps the
executable section as non-writable.

TODO:
- Add tests.
- Possibly decide on another mechanism for enabling this besides the -z flag
  (e.g. examine symbol version data on libc.so.6).





More information about the llvm-branch-commits mailing list