fix(relinker): reject guest TLS symbols in special sections #10731
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10731"
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 roboterspinne on 2026-10-24T19:56:50Z.
What
GuestImageReaderrejects a defined symbol whosest_shndxisSHN_LORESERVE(0xff00) or higher,SHN_ABSexcepted, but the check sat inside the(info & 15) != 6branch, soSTT_TLSsymbols skipped it. Onmaina guest module with aPT_TLSand anSTT_TLSsymbol inSHN_ABS,SHN_COMMON, 0xff00 orSHN_XINDEX(0xffff) relinks with exit 0 on Linux, whose output keeps the symbol in.dynsymwith that section index. Windows and macOS exit 2 withUnsupported guest export section: <name>only for an exported symbol outsideSHN_ABS; they drop anSHN_ABSexport (WindowsGuestModuleWriter.cpp:134,MacOsGuestModuleWriter.cpp:97) and, for a local symbol, writest_valueplus addend for anR_X86_64_DTPOFF64against it and exit 0.section >= 0xff00 && (section != AbsoluteSection || (info & 15) == 6)now fails with the existingUnsupported special symbol section: <name>, soSHN_ABSstays accepted for non-TLS symbols only and the non-TLS behaviour is unchanged. The gABI says a definedSTT_TLSsymbol "gives the assigned offset for the symbol, not the actual address", an offset in the module's TLS block;SHN_ABSmeans a value that relocation does not change,SHN_COMMONan unallocated common block that a shared object must allocate, and the other reserved indexes are processor-specific, OS-specific, unassigned or theSHN_XINDEXescape. The gABI gives anSTT_TLSsymbol no meaning in any of them; FreeBSD rtld usesst_valueof a defined TLS symbol whatever itsst_shndx, but the PS5 loader's handling is not measured, so the reader fails instead of picking a meaning. The macOS executable patcher already rejects TLS exports at or aboveSHN_LORESERVE(MacOsMachOPatcher.cpp:89), and open #10646 does the same for executable exports inRelinkerPipeline.cpp. The export-section checks atWindowsGuestModuleWriter.cpp:135andMacOsGuestModuleWriter.cpp:98can no longer be reached and stay for a follow-up. No issue and no test fixture has anSTT_TLSsymbol in a reserved section; the onlySHN_ABSguest symbols reported (PPSA12544, #698) areSTT_NOTYPEand stay accepted.test_guest_absolute_symbols.pygainstls_module, built onmodule_with_symbol(True)with aPT_TLS(vaddr 0x2380, filesz 8, memsz 0x40) and symbol 1 as a LOCAL or GLOBALSTT_TLSsymbol (value 0, size 8) with anR_X86_64_DTPOFF64against it. On Linux,--windowsand--macos, section 1 relinks with exit 0 in both bindings, andSHN_ABS,SHN_COMMON, 0xff00 and 0xffff exit 2 withUnsupported special symbol sectionand write nomodule.prx.guest.prx.convertnow takes the module bytes; the existing absolute and common cases are unchanged.pr_overlap.pyreports no overlap with open pull requests.Tested
Windows 11, GCC 15.2.0 (WinLibs UCRT), relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON); synthetic fixtures only, no title or homebrew, relinked outputs not run.main(2fade7ef4e): the extended test fails at its first special-section case withAssertionError: ('linux', '0xfff1', 0, ''), a LOCALSHN_ABSsymbol relinked with exit 0. Per target onmain: LOCAL in all four special sections and GLOBAL inSHN_ABSexit 0 on all three targets; GLOBAL in 0xfff2, 0xff00 and 0xffff exit 0 on Linux and 2 on Windows and macOS withUnsupported guest export section: shared.guest_absolute_symbolspasses in 2.5 s: the 24 special-section runs exit 2 withUnsupported special symbol section: sharedand write no artifact, the 6 section-1 runs exit 0. The 71 tests matchingguest|tls|absolute|symbolpass (33 s).ctest --test-dir build-relinker -j 4: 244 tests, 240 passed,long_pathsskipped;select_tests(Windows symlink fixture) andpatch_advisor_unit(build path with spaces, fix open in #10667) are known local failures onmain;shader_cache_runtime_sourcestimed out at 180 s under parallel load and passed when rerun alone (119 s).python tools/check_conventions.py --base upstream/mainwith this title and description passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:05:08Z.
Review: APPROVED
Reviewed the symbol-section validation and its regression coverage. TLS symbols are now rejected for SHN_ABS, SHN_COMMON, SHN_XINDEX and the other reserved indices, while ordinary SHN_ABS symbols and normal TLS sections retain their existing handling. The tests cover local/global bindings on Linux, Windows and macOS fixtures. The hosted relinker matrix, ASan and conventions checks all pass on this head. I found no blocking issue.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:19:56Z.
Review: APPROVED
Reviewed the complete diff at
21127fe316. The special-section guard now applies before TLS bounds validation and still permits SHN_ABS for non-TLS symbols; the new fixture exercises local/global TLS symbols across Linux, Windows and macOS output modes, including SHN_ABS, SHN_COMMON, SHN_LORESERVE and SHN_XINDEX. The reported main counter-check reproduces the prior acceptance, and the focused fixture plus 71 related tests passed locally on Windows; hosted Ubuntu, Windows, macOS arm64/x86_64 and ASAN relinker checks all passed. Product Linux/Windows jobs were skipped by repository workflow policy.