encounter / decomp-toolkit

A GameCube & Wii decompilation toolkit
Apache License 2.0
102 stars 14 forks source link

`elf disasm` fails at ELF entry address #4

Open muff1n1634 opened 11 months ago

muff1n1634 commented 11 months ago

When running elf disasm on an (unstripped) ELF file (from a Wii game), it fails with the message:

Failed: Range 0x00000000-{e_entry} outside of section .init: {.init->sh_addr}-{.init->sh_addr + .init->sh_size}

It may not happen on every ELF file, but I tried it on at least 10 and they all had the same result, so I think it probably does.

An actual example, from an actual game: Failed: Range 0x00000000-0x80004134 outside of section .init: 0x80004000-0x800064C4

Seems to be emitted from obj/sections.rs:152:

ensure!(
    self.contains_range(start..end),
    "Range {:#010X}-{:#010X} outside of section {}: {:#010X}-{:#010X}",
    start,
    end,
    self.name,
    self.address,
    self.address + self.size
);

I guess the problem is that it thinks the entry point is a range? No idea where that's determined, though.

i also don't know any rust i just grepped for the string


reproduction

  1. get an applicable ELF file
  2. dtk elf disasm <path/to/file.elf> .
  3. message, maybe

environment

OS: Windows 10 22H2 dtk -V: dtk 0.5.5 36bb5ddcc67dabaf5d00d7335a9e764c4c668ee7

also tried on macOS Catalina with 0.5.4 same stuff but im not on that computer rn so no specs

encounter commented 11 months ago

Unfortunately, trying to auto-split ELF files (especially Wii ones) turned out to not be very feasible after all. The file information available gets mangled pretty bad by the linker. But I'll still look to see if there's improvements to be made here.

Are you interested in setting up a decomp project for any of these, or just poking at disassembly?

muff1n1634 commented 11 months ago

I already have a project set up for another game with no symbols, but I wanted to see if I could set one up for a game with symbols so I could match the common libraries and move them over later. I thought since the ELFs have file names and boundaries (.text.1234 etc.) that elf disasm could split by object automatically, but for now I'll just set up splits manually. I've still got the symbols, so at least I don't have to do those by hand.

encounter commented 11 months ago

Cool! Check out dtk-template if you haven’t seen it already. It contains a template project structure and config documentation.

One solution may be to use elf config to extract a splits.txt and then fix it up manually.