Commit 1f01b1d
fix(ExecSolib): handle ET_EXEC trampoline in solib_bootstrap
The trampoline binary embedded in ddtrace.so is produced as ET_EXEC
(non-PIE) by toolchains that don't default to -fPIE (e.g. devtoolset-7
on CentOS 7). elf_load_trampoline previously accepted only ET_DYN and
used mmap(NULL) to pick a random load base -- an ET_EXEC binary loaded
that way runs at the wrong virtual address and crashes with SIGSEGV.
Two-pronged fix:
1. solib_bootstrap.c: accept both ET_DYN and ET_EXEC. For ET_EXEC,
reserve the binary's fixed virtual address range with MAP_FIXED
(valid in the bootstrap context: no ld.so yet, fresh address space).
2. libdatadog/spawn_worker/build.rs: add -fPIE/-pie on Linux so future
builds always produce a PIE (ET_DYN) trampoline, matching the
original design intent of elf_load_trampoline.
Fixes "failed to map trampoline" (exit 121) on bookworm-slim for
PHP 8.3-8.5.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent da0f6aa commit 1f01b1d
2 files changed
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
711 | | - | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
712 | 714 | | |
713 | 715 | | |
714 | 716 | | |
| |||
723 | 725 | | |
724 | 726 | | |
725 | 727 | | |
726 | | - | |
727 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
728 | 750 | | |
729 | 751 | | |
730 | 752 | | |
| |||
Submodule libdatadog updated 1 file
0 commit comments