Repository navigation
refactor(relinker): take the dynamic symbol type of TLS imports from the input symbol - #18161
Merged
oneandonlydean merged 1 commit intoNov 13, 2026
Conversation
Contributor
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On c548802 (line numbers below refer to it),
SysVDynamicSectionBuilder::BuildDynamicSectionwrites every import whose relocation isR_X86_64_DTPMOD64,DTPOFF64orTPOFF64with typeSTT_TLS, whatever type the input symbol has (tls ? STT_TLS : ref.SymbolType,core/relinker/relinker/src/output/SysVDynamicSectionBuilder.cpp:93-95). #12341 (d6e9570) made the pipeline reject every TLS relocation against an undefined symbol that is notSTT_TLS, and its description left removing this override for a follow-up, because the override no longer changes any type. This is that follow-up. The ELF gABI (Symbol Table,STT_TLS) states that thread-local storage relocations can only referenceSTT_TLSsymbols, and the pipeline enforces it before any import is recorded.NidReferenceis built for the output in one place,nidRefs.push_backinextractRela(core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp:441), withSymbolType=st_info & 15(line 439). A TLS relocation with symbol index 0 or against a definedSTT_TLSsymbol is folded and skipped (line 419).definedTlsSymbolValuethrows for an undefined symbol that is notSTT_TLS(lines 363-364) and for a defined one (367-368), and returnsstd::nulloptonly for an undefinedSTT_TLSsymbol (365-366). So every TLS reference that reaches line 441 already hasSymbolType==STT_TLS. The other direction is closed as well: a non-TLS relocation against anSTT_TLSsymbol throws (lines 423-424, #11881). Between extraction andBuildDynamicSection(line 602), theIUnusedNidFilter::Filtercalls at line 558 (strict filter, level 2) and line 577 (CFG/GOT filter, level 1) only copy a subset of the references (StrictNidFilter.cpp:209,UnusedNidFilter.cpp:46), andCompactPlt(line 596) copies the kept references and changes onlyRelocationTableOffsetofJUMP_SLOTreferences (PltCompactor.cpp:17,:34).RelocationTypeValueandSymbolTypestay as extracted. The only other caller of the builder isStrictNidFilterTests.cpp:554, which passesJUMP_SLOTreferences only. The written type now comes from the input symbol for every relocation type, and the output does not change for any input.symbolInforeturns the binding (STB_WEAKorSTB_GLOBAL) withref.SymbolTypefor every named import. The override and itstlslocal are removed. The unnamed import case (STB_WEAK,STT_NOTYPE) is unchanged. No check is added in the builder, because the pipeline already rejects every input that could reach it with another type.SymbolType, which the pipeline makes impossible. The existing guard istest_executable_tls_relocations.py:154: it expects the importedTPOFF64symbolImportedTlswith type 6 (STT_TLS) on Linux, and its fixture symbol hasst_info0x16 (line 50), so the type now comes fromref.SymbolType.test_call_registry.py(line 143) gives the symbol of its TLS casesst_info0x06.pr_overlap.py --branchreports no shared lines, exports or new files with the open pull requests, and lists no pull request it cannot compare. By hand on c548802: fix(relinker): load libSceGnmDriver.prx for a libSceGnmDriver_padebug dependency #18087 also changesSysVDynamicSectionBuilder.cpp, but inconsoleFileNames(line 82), not insymbolInfo, and a trial merge of this branch with fix(relinker): load libSceGnmDriver.prx for a libSceGnmDriver_padebug dependency #18087 is clean. Trial merges with my open pull requests fix(relinker): reject Linux relocations into non-writable PT_LOAD segments #13977, test(tools): compare run report fixtures with LF line endings on Windows checkouts #14369, fix(relinker): reject executable relocations against defined local, hidden or internal symbols #14370, fix(relinker): accept identical repeated dynamic tags in code analysis #14411 and fix(libSceSystemService): return PARAMETER from sceSystemServiceParamGetString for an unwritable buffer #14877 are clean as well.Tested
Windows 11, WinLibs GCC 15.2.0, relinker-only build directory configured with Ninja, Release,
-DANYPS5_RELINKER_ONLY=ONandBUILD_TESTING=ON, on this branch based on 697b66b. The baseline, the counter-check and the timeout note come from the same branch based on e907e6d; between the two bases no cited file and no file undercore/relinker/relinker/src/outputorsrc/pipelinechanged:core/relinker/relinker/src/outputorsrc/pipelinechanged (git diff --statis empty), so the tests were not rerun after the rebase.ctest --test-dir build-relinker -R '^(executable_tls_relocations|call_registry|call_registry_writer|strict_nid_filter|guest_tls|guest_tls_export_references|guest_own_tls_relocations|restricted_undefined_symbols_.*)$' --output-on-failure: 12/13 pass, and the 13th passes when rerun alone (see the timeout note below).cmake --build build-relinker --parallel 4, then the samectestcommand: 13/13 pass on 697b66b and on e907e6d.restricted_undefined_symbols_guest_7(20 s) on the baseline, andguest_own_tls_relocations(30 s) with the change, in an earlier run of the same command.STT_OBJECTfor anSTT_TLSinput type (not committed),ctest --test-dir build-relinker -R '^executable_tls_relocations$' --output-on-failurefailed attest_executable_tls_relocations.py:152with(4198432, 18, 'ImportedTls', 1, 0)instead of type 6. With the line restored it passes.python tools/check_conventions.py --base upstream/main --head HEAD(upstream/main at c548802) with 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)