Skip to content

Don't abandon the extab search at a gap between sections - #156

Open
oemasync wants to merge 1 commit into
encounter:mainfrom
oemasync:fix/extab-locator-section-gaps
Open

oemasync wants to merge 1 commit into
encounter:mainfrom
oemasync:fix/extab-locator-section-gaps

Conversation

@oemasync

Copy link
Copy Markdown

locate_extab_extabindex() probes for _eti_init_info at
section_end - ETI_INIT_INFO_SIZE * (num_text_sections + 1) and walks forward, reading a candidate table at each
address. A section's size can stop short of the next section: sizes come from _rom_copy_info, whose values are
rounded differently from the file's. The first candidate then lands in the gap, read_eti_init_info() fails
(Failed to locate section @ <addr>), and the ? on it abandons the search for the whole program — so
extab/extabindex are never named.

Consequences:

  • The game splits with no exception-table splits at all (silent, wrong output).
  • Once anything names an extabindex section, the split fails hard instead:
    Failed to find extab section.

Reproduction

dtk dol split on v1.8.4:

  • Sonic Adventure 2 Battle (GSNE8P) DOL: WARN Failed to locate extab/etabindex: Failed to locate section @ 0x80173124 (this program has no extab, so the warning was all you saw).
  • Animal Crossing (GAFE01) section layout: .init at 0x80003100 with a copied size of 0x2500 (file size
    0x2520), extab at 0x80005620, extabindex at 0x80005660, _eti_init_info at 0x80005684. Number of code
    sections is 2, so the first probe for the extab section is 0x80005648 - 48 = 0x80005618, which is in the gap
    between .init's copied end (0x800055F0/0x80005600) and 0x80005620 → Failed to locate section @ 0x80005618,
    and the exception tables are never named.

Change

  • Clamp the first candidate to the section start (saturating_sub(..).max(section_start)), so a small section can't
    underflow the probe below its own start.
  • Treat an unreadable candidate as "not this one" (continue) instead of returning an error for the whole program.
  • Give the end-of-table read in the second loop a message that says what it was doing.

Verification

  • Sonic Adventure 2 Battle DOL: no warning, and build/config.json, config/*/splits.txt, config/*/symbols.txt
    are byte-identical to v1.8.4 (the patch is inert for programs without exception tables).
  • Animal Crossing-layout DOL: the Failed to locate section @ 0x80005618 warning is gone and extab/extabindex
    are named, with @eti_* symbols created the way they are for every other game.

locate_extab_extabindex() probes for _eti_init_info starting at
section_end - ETI_INIT_INFO_SIZE * (num_text_sections + 1) and walks forward, reading
a candidate table at each address. A section's size can stop short of the next
section: sizes come from _rom_copy_info, whose values are rounded differently from the
file's. The first candidate then lands in the gap, read_eti_init_info() fails with
"Failed to locate section @ <addr>", and the `?` on it abandoned the search for the
whole program -- so extab/extabindex were never named.

The result is a game that splits with no exception-table splits at all, or, once
anything names extabindex, a hard failure: "Failed to find extab section".

Clamp the first candidate to the section start, and treat an unreadable candidate as
"not this one" instead of aborting. Also give the end-of-table read in the second loop
a message that says what it was doing.

Reproduced with v1.8.4 on Sonic Adventure 2 Battle's DOL ("Failed to locate section @
0x80173124", the program has no extab) and on a DOL with Animal Crossing's section
layout (.init 0x80003100 stopping at 0x800055F0, extab 0x80005620, extabindex
0x80005660, _eti_init_info 0x80005684), where the warning is gone after the change.
For the Sonic DOL the split output (config.json, splits.txt, symbols.txt) is
byte-identical to v1.8.4's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant