fix(relinker): drop input Linux PT_PHDR and PT_INTERP #2885
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2885"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T17:35:59Z.
What
The Linux patcher wrote its generated
PT_PHDRandPT_INTERPalongside copies from the input ELF. The stale inputPT_PHDRcan give glibc the pre-relink load bias and crash beforemain; copying both headers also consumes program-header slots. Filter the input headers and let the Linux writer emit its own entries.This carries ctj01's fix and regression test from danzaio's #2877, which closed at the intake gate before review. The original commit author is preserved.
Tested
Linux x86-64, GCC 12.2, Release relinker-only build. All 99 relinker CTests passed, including
linux_input_program_headers, which checks inputs with neither, either, or both headers; exact program-header slot counts; and execution through the generated entry stub. Conventions andgit diff --checkpassed.Danzaio also reported a MinGW 15.2 relinker-only build and structural checks passing on Windows; the test's execution check runs only on Linux. Full project builds were not run.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Fixes #2816
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T22:16:51Z.
Review: COMMENTED
The relinker is the part of this project I would most want a second pair of eyes on, so: the change reads right, and I checked the one thing that would have worried me.
The filter is Linux-only in practice.
SegmentFilteris constructed inmain.cppfor theLinuxElfPatcherbranch, so addingPT_PHDRandPT_INTERPtoShouldSkipcannot silently drop those entries for a target whose writer does not emit its own, and the existingtest_linux_program_header_orderalready pins that the Linux writer places both ahead of thePT_LOADentries. That is the cross-target risk I went looking for and did not find.One question about intent, since the input's interpreter is now ignored. With
PT_INTERPfiltered, the writer's own entry always wins. For a relink aimed at the host that is what you want; if the Linux writer is ever pointed at input naming a different interpreter, that distinction would be lost. Worth a word in the commit only if the case is reachable at all.The provenance is handled the way it should be — ctj01's fix and test, danzaio's PR closed at the intake gate, authorship preserved here. And the test is the right shape for this change: neither / either / both input headers, the exact program-header slot counts, and execution through the generated entry stub.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:13:30Z.
Checked on Linux x86-64: relinker build + ctest (94/94, incl.
linux_input_program_headers); the new test fails when theSegmentFilterchange is reverted and passes with it. No overlap with other open PRs; CI green on the current head. Merging.