Repository navigation
fself: don't read before the ELF when .sceversion is missing - #175
Open
TheErsysEnding wants to merge 1 commit into
Open
TheErsysEnding wants to merge 1 commit into
TheErsysEnding wants to merge 1 commit into
Conversation
elf_get_shstr_off() returns -1 when a section does not exist, and self_build_sceversion_header() then ran strlen() on elf_data - 1. ELFs built with the PSL1GHT rules have no .sceversion section, so this happened on every build. On Linux the stray read usually goes unnoticed and leaves a bogus offset and size in the fake SELF; on Apple Silicon macOS fself dies with SIGBUS, which stops "make" at the .self step. Leave section_idx, offset and str_size at zero when the section is absent. ELFs that do have the section produce the same output as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
On Apple Silicon macOS,
fselfcrashes withSIGBUSon every program built with the PSL1GHT rules. That stopsmakeat the.selfstep:self_build_sceversion_header()looks up the.sceversionsection, but ELFs built withppu_rulesdon't have one.elf_get_shstr_off()then returns-1, and the function callsstrlen((char*)elf_data - 1). AddressSanitizer reports:On Linux the stray read usually goes unnoticed. The fake SELF then carries a bogus
section_idx,offsetandstr_sizein its SCE version header.Fix
When the section is missing, the function now returns right after setting the constant fields.
section_idx,offsetandstr_sizestay at zero, because the struct is alreadymemsetto 0.Testing
Tested on macOS 27 on Apple Silicon, with the toolchain from ps3toolchain master:
ppu_rules(no.sceversion).sceversionsection added viappu-objcopy --add-section🤖 Generated with Claude Code