Skip to content

fix(relinker): map standalone RELRO in unused import filtering - #4717

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-relro-unused-filter
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-relro-unused-filter

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

unused-filter=1 could not read relocation tables or lifecycle arrays placed in a standalone PT_SCE_RELRO segment, even though the executable reader already maps that segment as a load segment. Reuse ElfReader::ReadProgramHeaders() in the relative relocation index and entry-point collector, so filtering uses the same mappings as conversion. Remove the obsolete filter limitation from technical debt.

Initialize e_version=1 and e_ehsize=64 in the separate relative-relocation bounds fixture. After #4441 added these header checks, that hand-built fixture still left both fields zero; using the shared reader exposed it before its positive bounds assertions. Keep the production header validation and all existing relocation-boundary assertions unchanged.

Tested

Windows, MinGW-w64 GCC 15.2.0, Release, relinker-only, main 2a2a3dc. Full build exits 0 and all 140 CTests pass in 24.40 s, including strict_nid_filter, elf_header, elf_reader_bounds, sce_relro, unused_filter_indirect and init_array_roots.

The review-reported failure was reproduced before correcting the fixture: strict_nid_filter exited 1 with Unsupported ELF object version: expected 1. The original 135-test Windows run included strict_nid_filter, but its base predates #4441's new object-version and header-size guards. Linux execution was not run locally.

Before the RELRO mapping fix, the added relocation and lifecycle cases failed with unmapped-address errors. The regressions cover standalone and already-covered RELRO, relocation tables, init arrays and filters 0, 1 and 2; retained imports are checked through the registry. git diff --check and committed branch/PR conventions pass. No game or console was run; no performance improvement is claimed.

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
  • Unblocks: none
  • AI-assisted: yes. — Codex

@nicolasfalesy

Copy link
Copy Markdown
Contributor

Linux test (Arch, GCC 16.2.1, Release), this PR's head merged alone onto main 7e181fc (clean merge): strict_nid_filter fails. Its last case prints Unsupported ELF object version: expected 1 after the two passing reachability cases. It passes on main on the same machine. The Windows run above was a relinker-only build; this test may not have been part of it.

@Ondra97
Ondra97 force-pushed the codex/fix-relro-unused-filter branch from 7a848dc to bde680c Compare October 13, 2026 09:22
@Ondra97

Ondra97 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I reproduced the failure after rebasing onto current main. The relative-relocation bounds fixture left e_version and e_ehsize at zero, which became invalid after #4441 added those checks.

Fixed in bde680c by initializing both fields. Production validation and the existing bounds assertions remain unchanged. The full Windows relinker build and all 140 CTests now pass. I have not run Linux locally.

The earlier 135-test run did include strict_nid_filter, but its base predated those new header checks.

AI-assisted: yes. — Codex

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on this head merged onto current main: relinker build and tests pass (124/124 in scope). With the production changes reverted, sce_relro fails (the new filter cases hit unmapped addresses) and passes with them; strict_nid_filter passes with the fixture fix, as expected. Relinker CI is green on Linux, Windows and macOS. Merging once the full Build is green.

@oneandonlydean
oneandonlydean merged commit f5cda83 into boykopovar:main Oct 14, 2026
10 checks passed
@Ondra97
Ondra97 deleted the codex/fix-relro-unused-filter branch October 17, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants