fix(relinker): accept RELATIVE relocations against a zero-value section symbol #4203
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4203"
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 saxopa on 2026-10-12T01:13:51Z.
What
Homebrew built with the OpenOrbis PS4 toolchain stops in the relinker on current
main(7a84b222). The OpenOrbisgraphicssample (toolchain v0.5.4,samples/graphics), relinked with--skip-sce-module:Cause: when create-fself copies
.rela.dyn, it adds one to every symbol index (OELFGenDynlibData.go#L818). lld writes all 2998 RELATIVE entries of the sample with symbol 0, and create-fself turns them into symbol 1, a localSTT_SECTIONsymbol with value 0. FreeBSD rtld computes RELATIVE asrelocbase + r_addendand never reads the symbol (amd64/reloc.c#L381-L383).The three readers that checked the index now accept index 0, or an in-range
STT_SECTIONsymbol with value 0. Any other symbol still throws, with the same messages.RelinkerPipeline: import scan, and the output RELATIVE table. That table used to skip RELATIVE entries with a nonzero index without an error. It now writes them with index 0.CodeInstructionCollector(Windows and macOS code analysis).StrictNidFilter(unused-filter=2).This is one item of #3093 ("R_X86_64_RELATIVE with symbol index 1"). With it, the sample converts to Linux with the default options and with
--to-intel.--windows,--macosandunused-filter=1stop at the next item of #3093,PT_SCE_RELRO. The PLTGOT at 0x130000 sits in that segment:unused-filter=2gets past the relocations and stops later withStrict filter: direct branch leaves code (offset 0xe40d3), which is out of scope here.Tested
macOS 27 (Apple Silicon), relinker-only Release build.
none_relocations: a symbol-1 RELATIVE entry against a zero-value section symbol, both layouts (standard and SCE tables), Linux, Windows and macOS output,unused-filter=0/1. The Linux output holds(0x300, 8, 0x210). ASTT_NOTYPEsymbol and a section symbol with value 0x10 are still rejected.strict_nid_filter: the same rule on the SCE dynlibdata fixture, plus an index outside the symbol table.main. Reverting any one of the three source files fails a test, and so does keeping the old drop in the output RELATIVE table.graphicssample: built locally with Apple clang, ld.lld and create-fself built from source at the commit above. Conversion results are listed above. Not run: no x86-64 Linux host here.python3 tools/check_conventions.py --base origin/mainpasses;git diff --checkis clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt — none added.mdfiles or images added to the repository (attach them to this PR)