relinker: PT_GNU_STACK and PT_GNU_RELRO are dropped from Linux output #6394
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 midasmatterhorn on 2026-10-15T13:56:07Z.
The Linux output silently drops
PT_GNU_STACKandPT_GNU_RELRO. On x86-64 Linux a main executable withoutPT_GNU_STACKis loaded with an executable stack (EXSTACK_DEFAULT), and withoutPT_GNU_RELROthe GOT and.dynamicstay writable after relocation — both weaker than what the guest module asked for.SegmentFilter::_isSceSpecificSegment(core/relinker/elfpatcher/src/general/SegmentFilter.cpp:6-16) treats everything in[PT_LOOS, PT_HIOS]as SCE-specific and drops it.PT_GNU_STACK(0x6474e551) andPT_GNU_RELRO(0x6474e552) live in that range; onlyPT_GNU_EH_FRAMEis rescued at line 15. Evidence that the drop is not intended:LinuxGuestModuleWriter.cpp:25deliberately adds aPT_GNU_STACKto guest-module output, andLinuxElfPatcher.cpp:100carries aPT_GNU_STACKspecial case inRebaseProgramHeadersthat is dead because the filter always removes the header first.Reproduced with a relinker-only build of
main92cdc7b62on macOS 27.0.1 arm64, on a minimalET_EXECfixture (codePT_LOAD+PT_DYNAMIC+ four extra headers; default options, exit code 0 in every row):PT_SCE_VERSION(baseline)PT_LOAD, PT_DYNAMIC, PT_PHDR, PT_NOTEPT_GNU_STACK(RW)PT_GNU_RELROSuggested fix: keep
PT_GNU_STACK(its addresses are 0,RebaseProgramHeadersalready handles it) andPT_GNU_RELRO(rebase its range like aPT_LOAD); or, if the input lacks one, synthesise a non-executablePT_GNU_STACKasLinuxGuestModuleWriterdoes.Found by an AI-assisted audit (DeepSeek V4.1 Flash via OpenCode); every row above was executed against the real
relinkerbinary. I can send the fix with regression tests.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T14:12:49Z.
The reported headers are dropped on current main. PR #6406 keeps both
PT_GNU_STACKandPT_GNU_RELROthrough segment filtering and adds normal/fixed-base integration coverage. The new CTest passes, and it fails against the current unmodified relinker becausePT_GNU_STACKis missing.