linux: Add PT_GNU_STACK to synthesized test module ELF

The DebugRendezvous.Self, ProcessReaderLinux.SelfModules, and
ProcessReaderLinux.ChildModules tests synthesize a minimal shared
object in memory and dlopen it. The generated ELF had no
PT_GNU_STACK program header, so glibc's loader treated it as
requiring an executable stack and asked the kernel to mark the
stack executable. Recent Linux kernels refuse that request,
causing dlopen to fail with "cannot enable executable stack as
shared object requires: Invalid argument".

Add a PT_GNU_STACK phdr with PF_R | PF_W so the loader knows
the module does not need an executable stack. e_phnum is
auto-derived from sizeof(phdr_table), so no other bookkeeping
is needed.

This is backwards-compatible: PT_GNU_STACK has been honored by
Linux, glibc, and binutils since ~2003 (Linux 2.6, glibc 2.3.3),
and loaders that do not recognize the OS-specific phdr type simply
ignore it. Declaring non-exec is strictly safer on both old and
new kernels.

Change-Id: I7ca40fe422520b4046590a2ff8b21285b7ccc7c8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/7750611
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
GitOrigin-RevId: 4f6597ac4d465ce28dde5c7a36e42bf8b5cab81f
1 file changed
tree: 5cd4e015d77bc8fe8528cade7e4938477c494e9c
  1. build/
  2. client/
  3. compat/
  4. doc/
  5. handler/
  6. infra/
  7. minidump/
  8. snapshot/
  9. test/
  10. third_party/
  11. tools/
  12. util/
  13. .clang-format
  14. .gitattributes
  15. .gitignore
  16. .gn
  17. .style.yapf
  18. .vpython3
  19. AUTHORS
  20. BUILD.gn
  21. codereview.settings
  22. CONTRIBUTORS
  23. DEPS
  24. LICENSE
  25. navbar.md
  26. OWNERS
  27. package.h
  28. README.md
README.md

Crashpad

Crashpad is a crash-reporting system.

Documentation

Source Code

Crashpad’s source code is hosted in a Git repository at https://chromium.googlesource.com/crashpad/crashpad.

Other Links