Skip to content

[BUG] Rebuilt REL drops the original's empty section slot, shifting every later section index #144

Description

@Jovinull

Repository URL

https://github.com/Jovinull/sonicheroes

Game Name

Sonic Heroes

Game Version

USA v0 (G9SE8P)

Description

This game's RELs reserve an empty section slot before .text, and the rebuilt
REL doesn't reproduce it. Every later section index comes out one lower, which
also shifts prologSection, epilogSection and unresolvedSection in the
header, so dtk can't read back its own output:

$ dtk rel info build/G9SE8P/autosaveD/autosaveD.rel
 WARN Attempted to visit non-code address 0:0x00001EF0
Failed: Failed to finalize block @ 0:0x00001EF0

Both files are 27800 bytes with numSections 20 and identical offsets. Only the
slots differ:

idx  original (off, exec, size)    rebuilt (off, exec, size)
  1  (236, 0, 0)                   (236, 1, 18416)
  2  (236, 1, 18416)               (18652, 0, 4)
  3  (18652, 0, 4)                 (18656, 0, 4)

prologSection / epilogSection / unresolvedSection:  original 2, rebuilt 1

The generated ldscript.lcf does emit .init before .text, but mwld drops it
since nothing lands in it, so the PLF has .text at index 1 and the placeholder
never reaches rel make. I tried five ways of forcing it to survive via
ldscript_template (*(.init), an ALIGN, a symbol assignment, . = . + 0;),
none of them keep it.

dtk v1.8.3, linker GC/1.3.2, ldflags -fp hardware -nodefaults, partial link
with -m _prolog -strip_partial. Same ldflags, linker and ldscript template as
zeldaret/tww, which reproduces 415 RELs, so I don't think this is a config
problem on my end. Their RELs just don't have the empty slot.

All 17 modules here are affected the same way, and the reference hashes are
already in config/G9SE8P/config.yml, so I can test a patch against all of them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions