fix(relinker): preserve imported ELF symbol types #10017

Merged
SteelCrab merged 2 commits from upstream-pr/10017 into main 2026-10-25 23:11:17 +00:00
SteelCrab commented 2026-10-23 04:12:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SteelCrab on 2026-10-23T04:12:38Z.


What

Preserve the input ELF symbol type when relinking named imports. Carry st_info & 0xf through NidReference::SymbolType and emit it in the SysV dynamic symbol table, so STT_NOTYPE, STT_OBJECT and STT_FUNC remain distinct. Existing TLS relocation handling and weak/global binding remain in place.

Add a regression covering all 16 type values with global/weak binding and GLOB_DAT/JUMP_SLOT relocations (64 conversion fixtures).

Replaces closed #8899 and addresses its STT_NOTYPE review.

Tested

Ubuntu 26.04.1 x86-64, GCC 15.2, Release. Based on main 9d6adeb5500c6b65e6591bc8e0a3c71b38c4b3e9; tested head 70329ada1c2039ab43ea7ba46143321b0d284db5.

  • Configured with ANYPS5_RELINKER_ONLY=ON and BUILD_TESTING=ON; Release build passed.
  • ctest --test-dir build-relinker --output-on-failure --parallel 3: 241/241 passed, including all 64 import_symbol_types conversion fixtures and the TLS regression coverage.
  • Prior negative control against the preceding implementation failed for STT_NOTYPE: input type 0 was emitted as type 1 (STT_OBJECT). Range-diff confirms both fix commits are unchanged by the latest rebase.
  • python3 tools/check_conventions.py --base origin/main, the complete PR-template check and git diff --check passed locally. The branch merges cleanly with the tested main.
  • python3 tools/pr_overlap.py --branch review/relinker-import-types completed. Manually inspected the shared files it could not compare: #5021 and #9408 add separate macOS test registrations, #6044 changes CMake test registration mechanically, and #8076 changes unwind/data-table scanning after import parsing. None implements this symbol-type preservation; no ordering dependency is required.

CI coverage: Build / relinker builds and runs the regression plus the relinker suite on Linux, Windows and macOS. For this first-time contributor, a maintainer must dispatch Build on main with this PR number and full=false. Conventions / conventions checks repository and PR rules automatically. No remote native build/test result is claimed; Windows and macOS were not run locally.

Remote status: Conventions passed and PR intake passed. Build is action_required; native CI is awaiting maintainer approval and is not a passing build result.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4977694348 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10017). Originally posted by [SteelCrab](https://github.com/SteelCrab) on 2026-10-23T04:12:38Z. --- ### What Preserve the input ELF symbol type when relinking named imports. Carry `st_info & 0xf` through `NidReference::SymbolType` and emit it in the SysV dynamic symbol table, so `STT_NOTYPE`, `STT_OBJECT` and `STT_FUNC` remain distinct. Existing TLS relocation handling and weak/global binding remain in place. Add a regression covering all 16 type values with global/weak binding and GLOB_DAT/JUMP_SLOT relocations (64 conversion fixtures). Replaces closed #8899 and addresses its [STT_NOTYPE review](https://github.com/boykopovar/AnyPS5/pull/8899#discussion_r4333229721). ### Tested Ubuntu 26.04.1 x86-64, GCC 15.2, Release. Based on main `9d6adeb5500c6b65e6591bc8e0a3c71b38c4b3e9`; tested head `70329ada1c2039ab43ea7ba46143321b0d284db5`. - Configured with `ANYPS5_RELINKER_ONLY=ON` and `BUILD_TESTING=ON`; Release build passed. - `ctest --test-dir build-relinker --output-on-failure --parallel 3`: **241/241 passed**, including all 64 `import_symbol_types` conversion fixtures and the TLS regression coverage. - Prior negative control against the preceding implementation failed for `STT_NOTYPE`: input type 0 was emitted as type 1 (`STT_OBJECT`). Range-diff confirms both fix commits are unchanged by the latest rebase. - `python3 tools/check_conventions.py --base origin/main`, the complete PR-template check and `git diff --check` passed locally. The branch merges cleanly with the tested main. - `python3 tools/pr_overlap.py --branch review/relinker-import-types` completed. Manually inspected the shared files it could not compare: #5021 and #9408 add separate macOS test registrations, #6044 changes CMake test registration mechanically, and #8076 changes unwind/data-table scanning after import parsing. None implements this symbol-type preservation; no ordering dependency is required. CI coverage: **Build / `relinker`** builds and runs the regression plus the relinker suite on Linux, Windows and macOS. For this first-time contributor, a maintainer must dispatch **Build** on main with this PR number and `full=false`. **Conventions / `conventions`** checks repository and PR rules automatically. No remote native build/test result is claimed; Windows and macOS were not run locally. Remote status: [Conventions passed](https://github.com/boykopovar/AnyPS5/actions/runs/39899102777) and [PR intake passed](https://github.com/boykopovar/AnyPS5/actions/runs/39899102850). [Build](https://github.com/boykopovar/AnyPS5/actions/runs/39899102773) is `action_required`; native CI is awaiting maintainer approval and is not a passing build result. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-23 04:22:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:22:31Z.

Review: APPROVED


Reviewed head 70329ada1c2039ab43ea7ba46143321b0d284db5. The parser carries the ELF st_info type into NidReference, and the dynamic symbol builder preserves that type while retaining TLS relocation handling and weak/global binding. The new fixture exercises all 16 type values under both bindings and both GLOB_DAT/JUMP_SLOT relocation paths. I found no blocking issue.

Validation on this exact head: Release relinker-only build completed; ctest -R ^import_symbol_types$ passed (1/1), and the relinker-labeled tests passed (3/3). The complete 241-test relinker-only CTest run had 239 passes and two unrelated failures: web_release (test_main_reconfigures_streams, argparse error-stream mock) and file_identity (SameFile accepted a missing file). Hosted Conventions and intake passed; hosted native build remains action_required pending maintainer dispatch, so I have not counted it as a pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623864791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10017#pullrequestreview-5623864791). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T04:22:31Z. **Review:** APPROVED --- Reviewed head `70329ada1c2039ab43ea7ba46143321b0d284db5`. The parser carries the ELF `st_info` type into `NidReference`, and the dynamic symbol builder preserves that type while retaining TLS relocation handling and weak/global binding. The new fixture exercises all 16 type values under both bindings and both GLOB_DAT/JUMP_SLOT relocation paths. I found no blocking issue. Validation on this exact head: Release relinker-only build completed; `ctest -R ^import_symbol_types$` passed (1/1), and the relinker-labeled tests passed (3/3). The complete 241-test relinker-only CTest run had 239 passes and two unrelated failures: `web_release` (`test_main_reconfigures_streams`, argparse error-stream mock) and `file_identity` (`SameFile accepted a missing file`). Hosted Conventions and intake passed; hosted native build remains `action_required` pending maintainer dispatch, so I have not counted it as a pass.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10017
No description provided.