Commit cc972fe
committed
[probably not for upstream] ELF: Add a -z glibc-228-compat flag for working around an old glibc bug.
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:
- Maybe drop this if it isn't needed?
- Add tests.
- Possibly decide on another mechanism for enabling this besides the -z flag
(e.g. examine symbol version data on libc.so.6).
Pull Request: llvm#1335321 parent d04aff4 commit cc972fe
3 files changed
+15
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
402 | 403 | | |
403 | 404 | | |
404 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1619 | 1619 | | |
1620 | 1620 | | |
1621 | 1621 | | |
| 1622 | + | |
1622 | 1623 | | |
1623 | 1624 | | |
1624 | 1625 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
2314 | 2327 | | |
2315 | 2328 | | |
2316 | 2329 | | |
| |||
0 commit comments