Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElfLoader: Don't scan for functions in zero-length sections #17435

Merged
merged 1 commit into from
May 8, 2023

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented May 8, 2023

This section has both GetSectionAddr and GetSectionSize returning 0.

			u32 start = reader.GetSectionAddr(id);
			// Note: scan end is inclusive.
			u32 end = start + reader.GetSectionSize(id) - 4;
			u32 len = end + 4 - start;

We end up with start = 0, end = 0xFFFFFFFC, len = 0 and Memory::IsValidRange returning true because len = 0 due to wraparound.

So we try to scan 0 to 0xFFFFFFFFC for functions, which causes problems.

Happens in WWE: Smackdown Vs Raw 2009 during initial load.

Fixes #12414 again (somewhat different problem this time).

@hrydgard hrydgard added the Loader label May 8, 2023
@hrydgard hrydgard added this to the v1.15.4 milestone May 8, 2023
We end up scanning a crazy range from 0 to 0xFFFFFFFFC, which causes
problems.

Happens in WWE: Smackdown Vs Raw 2009 during initial load.
@hrydgard hrydgard merged commit ba4f283 into master May 8, 2023
@hrydgard hrydgard deleted the wwe-scan-functions-fix branch May 8, 2023 15:48
@unknownbrackets
Copy link
Collaborator

This makes sense. Almost feels like GetCodeSections() shouldn't return sections that wouldn't be mapped to memory (i.e. sh_size != 0 or sectionAddrs[x] == 0. I guess this executable wasn't set to relocate, and had sh_addr == 0? Seems like we're probably outputting bad logs for this ELF.

-[Unknown]

@hrydgard
Copy link
Owner Author

hrydgard commented May 9, 2023

Yeah, we can probably clean this up quite a bit. Didn't do it because I wanted a minimal fix for the release, of course - more appropriate to do later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WWE 2009 - crash in loading game screen. (Android/Windows)
2 participants