fix(relinker): add icons to generated Windows executables #350
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/350"
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 QDarkRex on 2026-10-02T11:35:53Z.
What
Embed
sce_sys/icon0.pngbeside the input executable as a PNGRT_ICONwith anRT_GROUP_ICONin a read-only.rsrcsection. Preserve the PNG bytes, including images larger than 256x256. Missing icons leave resource directory 2 empty. Invalid PNG signatures, IHDR fields, chunk bounds or CRCs fail with the icon path in aRelinkerException.Use only the C++20 standard library. No new flags or dependencies. Remove the resolved executable-icon technical debt entry. Based on
e1654a97.A malformed
icon0.pngfails the relink rather than being skipped; removing the file relinks without an icon.Tested
Windows 11 Home Single Language, build 26200; MinGW-w64 GCC 15.2, Release: all 16 relinker tests pass. The new test fails against unpatched
e1654a97with missing icon resources. It checks the resource tree, group metadata, unchanged PNG bytes, missing icons and 11 malformed files. Windows runs also extract icons and execute the relinked fixtures; non-Windows runs check relinking and resource bytes.Manual Windows check: Explorer displays generated icons from 32x32, 256x256, 512x512 and 1024x1024 PNGs. A relinked window fixture loads group resource 1 from its executable and displays the 512x512 icon in the title bar and taskbar. Screenshot: the relinked window fixture showing the embedded 512x512 icon in its title bar. No game binaries tested.
Linux: Ubuntu 24.04, GCC 13.3, Release: all 16 relinker tests pass; the new test fails against unpatched
e1654a97.llvm-readobj --coff-resourcesparses the generated resource tree (ICON and GROUP_ICON, ID 1, language 0) and the PNG is embedded byte-for-byte. Withouticon0.png, the output is byte-identical to unpatchede1654a97.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T11:39:51Z.
Nice work. ELF has no icon resource, so I'll open a separate PR for the Linux side: next to the output it writes a freedesktop
.desktopentry pointing at a copy ofsce_sys/icon0.png(title taken fromsce_sys/param.json). It won't touch the files or lines changed here, so the two PRs don't conflict.Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-10-02T11:43:34Z.
Thanks! A .desktop entry sounds like the right equivalent for Linux. Since it reads the same file, the PNG validation in WindowsIconResourceBuilder.cpp could be shared if useful.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T11:48:45Z.
Thanks! Opened #353. It keeps a minimal signature/IHDR check so the two PRs stay independent and conflict-free; once this one lands I'll follow up moving
validatePngto a shared place and use it from both sides.One note on the test: CONTRIBUTING says Python is optional and that without it some relinker tests aren't registered, so
test_windows_icon.pymay silently not run. In #353 I wrote it as a C++ test that calls the writer directly (elfpatcher/tests/LinuxDesktopEntryTests.cpp, likefile_writer_tests) so it always runs with ctest. A C++ test overWindowsIconResourceBuilderwould get the same guarantee here.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T11:55:02Z.
The red Linux check isn't caused by this PR: the relinker tests all pass, including
windows_icon. The failure isagc_driver_vopc_compareon lavapipe (thread 1 compare 39 is 0, expected 1). That's a shader test from my #259. The same failure, with the same thread and compare, shows up in unrelated PRs that ran at about the same time (pr/savedata-delete-dir-name,fix/kernel-nooverwrite-win,fix/tlou-runtime-funcs). Other runs on the same basee1654a97(main, #353) pass with the same image and Mesa. I'm looking into it on my side; a CI re-run should get this one green.Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-10-02T13:54:34Z.
Added elfpatcher/tests/WindowsIconResourceTests.cpp, registered without the Python condition so it always runs with ctest. It checks the empty and missing icon cases, the .rsrc tree entries and the unchanged PNG bytes, and that a malformed PNG fails with its path. test_windows_icon.py stays for the end-to-end check through the relinker.
Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-10-02T14:23:07Z.
Thanks for looking into the
agc_driver_vopc_comparefailure! In case it helps narrow it down: it now shows up on main too. The push build of313de1c(merge of #289) fails with the samethread 1 compare 39 is 0, expected 1, and so doesfeat/sync-on-address. Happy to run anything on my side if that's useful.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T01:43:57Z.
This now conflicts with main: #430 added its TechnicalDebt line in the same place. Could you rebase? Otherwise it looks good to merge.
Imported from boykopovar/AnyPS5. Originally posted by QDarkRex on 2026-10-04T03:38:33Z.
Rebased onto main (
33a2f90). The only conflict was the TechnicalDebt line: the icon entry is removed and #430's--to-intelwording is kept as is. Relinker tests pass on Windows (MinGW 15.2) and Linux (GCC 13), includingwindows_iconandwindows_icon_resource. Thanks for the review!