Coder Social home page Coder Social logo

decomp-toolkit's Introduction

decomp-toolkit Build Status

Yet another GameCube/Wii decompilation toolkit.

decomp-toolkit functions both as a command-line tool for developers, and as a replacement for various parts of a decompilation project's build system.

For use in a new decompilation project, see dtk-template, which provides a project structure and build system that uses decomp-toolkit under the hood.

Sections

Goals

  • Automate as much as possible, allowing developers to focus on matching code rather than months-long tedious setup.
  • Provide highly accurate and performant analysis and tooling.
  • Provide everything in a single portable binary. This simplifies project setup: a script can simply fetch the binary from GitHub.
  • Replace common usages of msys2 and GNU assembler, eliminating the need to depend on devkitPro.
  • Integrate well with other decompilation tooling like objdiff and decomp.me.

Background

The goal of a matching decompilation project is to write C/C++ code that compiles back to the exact same binary as the original game. This often requires using the same compiler as the original game. (For GameCube and Wii, Metrowerks CodeWarrior)

When compiling C/C++ code, the compiler (in our case, mwcceppc) generates an object file (.o) for every source file. This object file contains the compiled machine code, as well as information that the linker (mwldeppc) uses to generate the final executable.

One way to verify that our code is a match is by taking any code that has been decompiled, and linking it alongside portions of the original binary that have not been decompiled yet. First, we create relocatable objects from the original binary:

Binary split diagram

(Heavily simplified)

Then, each object can be replaced by a decompiled version as matching code is written. If the linker still generates a binary that is byte-for-byte identical to the original, then we know that the decompiled code is a match.

decomp-toolkit provides tooling for analyzing and splitting the original binary into relocatable objects, as well as generating the linker script and other files needed to link the decompiled code.

Analyzer features

Function boundary analysis
Discovers function boundaries with high accuracy. Uses various heuristics to disambiguate tail calls from inner-function control flow.

Signature analysis
Utilizes a built-in signature database to identify common Metrowerks and SDK functions and objects.
This also helps decomp-toolkit automatically generate required splits, like __init_cpp_exceptions.

Relocation analysis
Performs control-flow analysis and rebuilds relocations with high accuracy.
With some manual tweaking (mainly in data), this should generate fully-shiftable objects.

Section analysis
Automatically identifies DOL and REL sections based on information from signature and relocation analysis.

Object analysis
Attempts to identify the type and size of data objects by analyzing usage.
Also attempts to identify string literals, wide string literals, and string tables.

Splitting
Generates split object files in memory based on user configuration.
In order to support relinking with mwldeppc.exe, any unsplit .ctors, .dtors, extab and extabindex entries are analyzed and automatically split along with their associated functions. This ensures that the linker will properly generate these sections without any additional configuration.
A topological sort is performed to determine the final link order of the split objects.

Object file writing
Writes object files directly, with no assembler required. (Bye devkitPPC!)
If desired, optionally writes GNU assembler-compatible files alongside the object files.

Linker script generation
Generates ldscript.lcf for mwldeppc.exe.

Future work

  • Support RSO files
  • Add more signatures

Commands

ar create

Create a static library (.a) from the input objects.

$ dtk ar create out.a input_1.o input_2.o
# or
$ echo input_1.o >> rspfile
$ echo input_2.o >> rspfile
$ dtk ar create out.a @rspfile

ar extract

Extracts the contents of static library (.a) files.

Accepts multiple files, glob patterns (e.g. *.a) and response files (e.g. @rspfile).

Options:

  • -o, --out <output-dir>: Output directory. Defaults to the current directory.
  • -v, --verbose: Verbose output.
  • -q, --quiet: Suppresses all output except errors.
# Extracts to outdir
$ dtk ar extract lib.a -o outdir

# With multiple inputs, extracts to separate directories
# Extracts to outdir/lib1, outdir/lib2
$ dtk ar extract lib1.a lib2.a -o outdir

demangle

Demangles CodeWarrior C++ symbols. A thin wrapper for cwdemangle.

$ dtk demangle 'BuildLight__9CGuiLightCFv'
CGuiLight::BuildLight() const

disc info

disc commands are wrappers around the nod library and its nodtool command line tool.

Displays information about disc images.

Supported disc image formats:

  • ISO (GCM)
  • WIA / RVZ
  • WBFS (+ NKit 2 lossless)
  • CISO (+ NKit 2 lossless)
  • NFS (Wii U VC)
  • GCZ
$ dtk disc info /path/to/game.iso

disc extract

Extracts the contents of disc images to a directory.

See disc info for supported formats.

$ dtk disc extract /path/to/game.iso [outdir]

By default, only the main data partition is extracted.
Use the -p/--partition option to choose a different partition.
(Options: all, data, update, channel, or a partition index)

disc convert

Converts any supported disc image to raw ISO (GCM).

If the format is lossless, the output will be identical to the original disc image.

See disc info for supported formats.

$ dtk disc convert /path/to/game.wia /path/to/game.iso

disc verify

Hashes the contents of a disc image and verifies it against a built-in Redump database.

See disc info for supported formats.

$ dtk disc verify /path/to/game.iso

dol info

Analyzes a DOL file and outputs information section and symbol information.

$ dtk dol info input.dol

dol split

Note

This command is a work-in-progress.

Analyzes and splits a DOL file into relocatable objects based on user configuration.

This command is intended to be used as part of a decompilation project's build system.
For an example project structure and for documentation on the configuration, see dtk-template.

$ dtk dol split config.yml target

dol diff

Simple diff tool for issues in a linked ELF. (Yes, not DOL. It's misnamed.)
Tries to find the most obvious difference causing a mismatch.

Pass in the project configuration file, and the path to the linked ELF file to compare against.

$ dtk dol diff config.yml build/main.elf

dol apply

Applies updated symbols from a linked ELF to the project configuration. (Again, misnamed.)

Useful after matching a file. It will pull updated symbol information from the final result.

$ dtk dol apply config.yml build/main.elf

dol config

Generates an initial project configuration file from a DOL (& RELs).

Pass in the DOL file, and any REL files that are linked with it.
Or, for Wii games, pass in the selfile.sel. (Not RSOs)

$ dtk dol config main.dol rels/*.rel -o config.yml

dwarf dump

Dumps DWARF 1.1 information from an ELF file. (Does not support DWARF 2+)

$ dtk dwarf dump input.elf

elf disasm

Disassemble an unstripped CodeWarrior ELF file. Attempts to automatically split objects and rebuild relocations when possible.

$ dtk elf disasm input.elf out

elf fixup

Fixes issues with GNU assembler-built objects to ensure compatibility with mwldeppc.exe.

  • Strips empty sections
  • Generates section symbols for all allocatable sections
  • Where possible, replaces section-relative relocations with direct relocations.
  • Adds an (asm) suffix to the file symbol. (For matching progress calculation)
# input and output can be the same
$ dtk elf fixup file.o file.o

elf2dol

Creates a DOL file from the provided ELF file.

$ dtk elf2dol input.elf output.dol

map

Processes CodeWarrior map files and provides information about symbols and TUs.

$ dtk map entries Game.MAP 'Unit.o'
# Outputs all symbols that are referenced by Unit.o
# This is useful for finding deduplicated weak functions,
# which only show on first use in the link map.

$ dtk map symbol Game.MAP 'Function__5ClassFv'
# Outputs reference information for Function__5ClassFv
# CodeWarrior link maps can get very deeply nested,
# so this is useful for emitting direct references
# in a readable format.

rel info

Prints information about a REL file.

$ dtk rel info input.rel

rel merge

Merges a DOL file and associated RELs into a single ELF file, suitable for analysis in your favorite reverse engineering software.

$ dtk rel info main.dol rels/*.rel -o merged.elf

rso info

Warning

This command is not yet functional.

Prints information about an RSO file.

$ dtk rso info input.rso

shasum

Calculate and verify SHA-1 hashes.

$ dtk shasum baserom.dol
949c5ed7368aef547e0b0db1c3678f466e2afbff  baserom.dol

$ dtk shasum -c baserom.sha1 
baserom.dol: OK

nlzss decompress

Decompresses NLZSS-compressed files.

$ dtk nlzss decompress input.bin.lz -o output.bin
# or, for batch processing
$ dtk nlzss decompress rels/*.lz -o rels

rarc list

Lists the contents of an RARC (older .arc) archive.

$ dtk rarc list input.arc

rarc extract

Extracts the contents of an RARC (older .arc) archive.

$ dtk rarc extract input.arc -o output_dir

u8 list

Extracts the contents of a U8 (newer .arc) archive.

$ dtk u8 list input.arc

u8 extract

Extracts the contents of a U8 (newer .arc) archive.

$ dtk u8 extract input.arc -o output_dir

yay0 decompress

Decompresses Yay0-compressed files.

$ dtk yay0 decompress input.bin.yay0 -o output.bin
# or, for batch processing
$ dtk yay0 decompress rels/*.yay0 -o rels

yay0 compress

Compresses files using Yay0 compression.

$ dtk yay0 compress input.bin -o output.bin.yay0
# or, for batch processing
$ dtk yay0 compress rels/* -o rels

yaz0 decompress

Decompresses Yaz0-compressed files.

$ dtk yaz0 decompress input.bin.yaz0 -o output.bin
# or, for batch processing
$ dtk yaz0 decompress rels/*.yaz0 -o rels

yaz0 compress

Compresses files using Yaz0 compression.

$ dtk yaz0 compress input.bin -o output.bin.yaz0
# or, for batch processing
$ dtk yaz0 compress rels/* -o rels

decomp-toolkit's People

Contributors

1superchip avatar cadmic avatar dazombiekiller avatar encounter avatar ribbanya avatar sewer56 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

decomp-toolkit's Issues

`dol diff`: Conditionally warn on symbol size mismatch

Right now, a symbol size mismatch will error and halt the diff. This is annoying for symbols where the true size was discovered and symbols.txt hasn't yet been updated to reflect. If the next symbol is still at the correct address (meaning that alignment was not broken), omit a warning instead and continue.

Failure to load DOL

Game: Bloody Roar: Primal Fury
Revision: 0
Region: NTSC (US)

 INFO Loading config\GBLE52\config.yml
 INFO Loading and analyzing 1 module (using 1 thread)
Failed: While loading object 'main.dol'

Caused by:
    Failed to finalize block @ 3:0x80084054

[ISSUE] Multiple sections with name .rodata

Repository URL

No response

Game Name

Wii Sports Resort

Game Version

USA v1.1

Description

While trying to analyze the game, I get the error of "Multiple sections with name .rodata". From what I understand, the dol file has a duplicate segment with the same name, but looking at it in IDA it seems like both contain different data. Is there any possible way of specifying the segment it should use?

Error: Section symbol without section

Lots of elf files in the debugging.games archive fail to disassemble with similar errors. These look like linker-defined symbols which do not actually correspond to source locations. For example:

Megaman.elf:

Section symbol without section: Symbol { name: "_stack_end", address: 2149095232, size: 0, kind: Data, section: Absolute, scope: Dynamic, weak: false, flags: Elf { st_info: 17, st_other: 0 } }

smash.elf:

Section symbol without section: Symbol { name: "__SBSS2_END__", address: 2149515028, size: 0, kind: Data, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: 17, st_other: 0 } }

dwarf dump using class in place of struct

I've noticed that dwarf dump are setting classes as structs and structs as classes. Apparently in struct and class members it's defining in the right way. Here's an example:
image

[BUG] failed to analyze Goldeneye Wii (SJBE52)

Repository URL

https://github.com/Coockie1173/Goldeneye-Wii

Game Name

GoldenEye Wii

Game Version

USA

Description

When splitting the game, it throws the following error:

build\tools\dtk.exe dol split config\SJBE52\config.yml build\SJBE52
INFO Loading config\SJBE52\config.yml
INFO Loading and analyzing 1 module (using 1 thread)
WARN module{name=main}: Control flow from 3:0x803AB514 hit known function 3:0x803AB55C (instruction: 3:0x803AB55C)
INFO Initial analysis completed in 0.969s (found 14036 functions)
INFO Rebuilding relocationninja: error: rebuilding 'build.ninja': subcommand failed
s and splitting
Failed: While processing object 'main.dol' (module ID 0)

[BUG] `addic.`/`subic.` is not considered when analyzing relocations

Repository URL

https://github.com/DarkRTA/rb3

Game Name

Rock Band 3

Game Version

SZBE69_B8

Description

The lis/subic. instruction pair here is not marked as a relocation like it should be.

image

So far I've identified this issue in the following locations:

  • band3/meta_band/AccomplishmentCategory.cpp - AccomplishmentCategory::HasAward()
  • band3/meta_band/AccomplishmentGroup.cpp - AccomplishmentGroup::HasAward()
  • system/utl/HxGuid.cpp - HxGuid::Generate()

[BUG] Handwritten addresses are interpreted as pointers

Repository URL

https://github.com/Yanis42/oot-gc-dtk

Game Name

Zelda: Ocarina of Time - Master Quest and Collector's Edition N64 Emulator

Game Version

Any

Description

dtk is interpreting N64 addresses written in code as pointers, this makes the assembly harder to understand once decompiled (and it's giving a fake diff), the current workaround is to use noreloc (which is what I used on the systemSetupGameALL symbol)

to find these addresses in the source files you can look for calls of cpuSetCodeHack

Add `-o` to `shasum`

> on Windows writes UTF-16. An -o option lets us write a UTF-8 file directly.

Issues with splitting ELF

 INFO Loading default.elf    
 INFO Splitting 949 objects    
Failed: Range 0x00000000-0x80004380 outside of section .init: 0x80004000-0x80006728

relevant part from the info output:

          .text | 0x800562E4 | 0x4        | sqrt      
          .text | 0x800562E8 | 0x4        | strdup    
          .text | 0x800562EC | 0x54       | strlwr    
          .text | 0x80056340 | 0xA0       | stricmp   
          .init | 0x80004380 | 0x0        | gTRKInterruptVectorTable
          .init | 0x800062B4 | 0x0        | gTRKInterruptVectorTableEnd
          .text | 0x800563E0 | 0x0        | TRKAccessFile
          .text | 0x800563E8 | 0x0        | TRKOpenFile
          .text | 0x800563F0 | 0x0        | TRKCloseFile

Initially I thought this was because the symbol was 0 sized, but then had the same issue with a different ELF

Failed: Range 0x00000000-0x80004300 outside of section .init: 0x80004000-0x800066BC
           .bss | 0x804DF8E0 | 0x30       | __OSExpireAlarm
          .text | 0x80293190 | 0x158      | __OSInitPlayTime
        .rodata | 0x80465688 | 0x40       | @LOCAL@OSCalcCRC32__FPCvUl@crc32_table
          .text | 0x802932F0 | 0x134      | OSCalcCRC32
          .text | 0x80293430 | 0x204      | __OSRelaunchTitle
          .init | 0x80004300 | 0x24       | __init_hardware
          .text | 0x80293640 | 0x20       | __init_user
          .text | 0x802936B0 | 0x4C       | exit      
          .init | 0x80004330 | 0x34       | __flush_cache
          .text | 0x80293700 | 0x2C       | PSMTXIdentity
          .text | 0x80293730 | 0x34       | PSMTXCopy 

diff for RELs

It would be nice to have something like ninja diff working for RELs. A use case can be found in https://github.com/robojumper/ss-dtk/tree/rel-wip (SOUE01) - with the latest commit on that branch, objdiff shows no difference, but checksum verification for the d_t_tackle REL fails for not immediately obvious reasons.

The reason in this case is that two virtual function overrides were (accidentally) swapped in the symbols, which resulted in an incorrect vtable after linking, but to figure this out I had to binary diff the whole REL in a hex editor - which is doable for a small REL like this but scales poorly.

Rework section alignment handling

Section alignment is handled haphazardly. Ways to improve:

  • Honor splits.txt alignment values when writing ldscript.lcf
  • Add alignment values to ldscript_partial.lcf, remove hacky code from rel make
  • Guess alignment values in DOL loader

Skip Invalid Instructions

Just Dance 2 (Best Buy Edition), along with presumably any game using MetaFortress, deliberately create invalid instructions as an anti-piracy measure. Currently, dtk hard-fails when encountering an invalid instruction, such as when splitting out the dol. Instead, it should silently ignore invalid instructions and continue with analysis.

Files with more than one period in their name are not properly named when split

I came across this when I was decomposing MSL; in particular, there's a file named sysenv.GCN.o as specified by some unstripped .elf files, so I added it to my splits

extern/msl/libc/embedded/sysenv.GCN.c:
	.text       start:0x804385FC end:0x80438604

but running dtk dol split (dtk/config.yml disasm) produces the following:

> ls -la disasm/obj/extern/msl/libc/embedded | grep sysenv
-rw-r--r-- 1 muffin None  540 Dec 17 15:15 sysenv.o

reproduction

  1. add a file to splits.txt with a name with multiple periods in it like a.b.c
  2. split the dol
  3. check filename. will probably be missing infixes

environment

OS: Windows 10 22H2
dtk -V: dtk 0.6.4 0cfc5df20b4d03604649afb88897d4e011fc9b26

Feature: Extract embedded assets

Use case: Large assets embedded in the binary. decomp-toolkit should be able to extract and convert them to C headers that can be included.

Dwarf dump not extracting all data from elf

I've tried to dump the Dwarf from Gamecube's FIFA 2004 and with the last version it worked really well, but I noticed that the dump missed some functions and global variables, even with their data present in elf. For example, the data from global gPassTri is present here:
image
But this data and the data around that are not present in the dump

[BUG] "Found invalid relocation" when setting up RELs

Repository URL

https://github.com/robojumper/ss-dtk/tree/dtk-invalid-rel

Game Name

Skyward Sword

Game Version

NTSC v1.0

Description

Provide the main.dol and RELs, then run ninja in the provided branch

Failed: While processing object 'd_a_b_bigboss2NP.rel' (module d_a_b_bigboss2NP ID 122)

Caused by:
    Found invalid relocation 0:0x99C4 Lo(
        Address(
            4:0x10FC,
        ),
    ) (target 4:0x10FC) in relocatable object

Adding

  block_relocations:
    - source: .text:0x000099C4

does not seem to work around this.

Improve Error Handling when startAddr > endAddr

DTK currently throws a "cryptic" error when the start address of a split is greater than the end of the split.

 INFO Loading config\SB4E01\config.yml
 INFO Loading and analyzing 1 module (using 1 thread)
 INFO Initial analysis completed in 6.283s (found 50349 functions)
 INFO Rebuilding relocations and splitting
thread '<unnamed>' panicked at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce\library\alloc\src\collections\btree\search.rs:120:21:
range start is greater than ninja: error: rebuilding 'build.ninja': subcommand failed  
range end in BTreeMap
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

dtk insists that a function is in ctors, but it's in text

Repository URL

https://github.com/ribbanya/melee/tree/8daa8eb261ccd111d7595bc73405607b2fb4cd5d

Game Name

Super Smash Bros. Melee

Game Version

GALE01

Description

dtk keeps placing a function, whose definition is in .text, but is referenced from .ctors, in .ctors. Well, more accurately, it keeps creating a ctors split where that function is. The function is __sinit_trigf_c.

I'm not sure this is a bug. I would be entirely unsurprised if this is due to us doing something wrong, since as you can see __ctors are not properly implemented in C.

Add functionality to differentiate between multiple target symbols in config.yml `add_relocations`

Currently, there is no way to disambiguate between multiple symbols of the same name when adding relocations via config.yml. A very notable case would be adding a relocation to a string pool, as there could be hundreds or thousands of @stringbase0 symbols that exist in a project.

This could be done by splitting the target field into two targetName and targetLocation fields, which hold the symbol name and address respectively. There could also be some way of combining the two fields (this is what I instinctively tried in the config.yml - @stringbase0:0x80b895e8), but it could be difficult to determine where the symbol ends and where the location begins.

'Rebuilding relocations and splitting' index out of bounds crash with OoT JP Wii VC

While following dtk-template Getting Started using the OoT JP Wii VC 00000001.app (.app sha1 47546e48467ae14d712b8c207e911821586d1043) as the dol (renaming 00000001.app -> main.dol) I encountered the following crash:

$ ninja
[1/3] TOOL build/tools/dtk
Downloading https://github.com/encounter/decomp-toolkit/releases/download/v0.6.2/dtk-linux-x86_64 to build/tools/dtk
[2/3] SPLIT config/NACJ/config.yml
FAILED: build/NACJ/config.json
build/tools/dtk dol split config/NACJ/config.yml build/NACJ
 INFO Loading config/NACJ/config.yml
 INFO Loading and analyzing 1 module (using 1 thread)
 WARN module{name=oot_vc}: Conflicting size for Control: was 0x190, now 0x18C
 WARN module{name=oot_vc}: Conflicting size for Control: was 0x190, now 0x18C
 WARN module{name=oot_vc}: Conflicting size for InitMetroTRK: was 0x94, now 0x98
 INFO Initial analysis completed in 0.825s (found 4323 functions)
 INFO Rebuilding relocations and splitting
thread '<unnamed>' panicked at src/obj/symbols.rs:308:36:
index out of bounds: the len is 0 but the index is 18446744073709551615
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)
ninja: error: rebuilding 'build.ninja': subcommand failed

The same crash occurs if I manually run (on the 0.6.4 release)

./dtk dol config main.dol -o config.yml
./dtk dol split config.yml output

Fix `dol apply`

Right now it has a few bugs:

  • gap_ symbols are added
  • Symbols with unknown visibility are set to global

Feature: Implement YAY0 Decompression

Luigi's Mansion's executable contains YAY0-compressed assets, so support for YAY0 decompression would be appreciated. A C implementation of the decompression algorithm can be found here.

[BUG] Control flow issues when attempting to analyze or merge F-Zero GX DOL with REL files

Repository URL

No response

Game Name

F-Zero GX

Game Version

USA, Japan

Description

When attempting to analyze the F-Zero GX dol with the dol info command, control flow errors are returned. Furthermore, when attempting to merge the DOL and REL files together to create an ELF which can be statically analyzed, even more control flow errors are returned, along with a "Tail call analysis" failure.

image

Infer and trim padding at the end of TU sections

Given a TU with correctly assigned symbol sizes, dtk should be able to infer the unpadded endings of splits, like this:

 melee/ft/chara/ftPurin/ftPr_SpecialHi.c:
     .text       start:0x8013C9C8 end:0x8013CE8C
-     .sdata2     start:0x804D9C10 end:0x804D9C20
+     .sdata2     start:0x804D9C10 end:0x804D9C1C
 
 melee/ft/chara/ftPurin/ftPr_SpecialLw.c:
     .text       start:0x8013CE8C end:0x8013D234
     .sdata2     start:0x804D9C20 end:0x804D9C2C

Handle `lbzx` relocations

dtk fails to detect a relocation in GetMesMaxSizeSub in mario party 4.

 /* 800473F0 00044250  88 7F 00 00 */    lbz r3, 0x0(r31)
 /* 800473F4 00044254  38 63 89 A9 */    subi r3, r3, 0x7657
 /* 800473F8 00044258  7F A3 68 AE */    lbzx r29, r3, r13

the relevant code is this. 0x7657 points to mesWInsert-0x1 which is equivalent to winTabSize
this code translates to

var_r29 = mesWInsert[*var_r31 - 1];

[BUG] Failed to analyze SSBB

Repository URL

https://github.com/wowjinxy/dtk-brawl

Game Name

Super Smash Brothers Brawl

Game Version

RSBE01

Description

E:\dtk-brawl>ninja
[1/3] TOOL build\tools\dtk.exe
Downloading https://github.com/encounter/decomp-toolkit/releases/download/v0.7.5/dtk-windows-x86_64.exe to build\tools\dtk.exe
[2/3] SPLIT config\RSBE01\config.yml
FAILED: build/RSBE01/config.json
build\tools\dtk.exe dol split config\RSBE01\config.yml build\RSBE01
INFO Loading config\RSBE01\config.yml
INFO Loading and analyzing 127 modules (using 16 threads)
ERROR module{name=sora_scene}: Failed to finalize functions:
ERROR module{name=sora_scene}: 0:0x000221D0
ERROR module{name=sora_scene}: 0:0x00022D3C
ERROR module{name=sora_scene}: 0:0x000234F4
ERROR module{name=sora_scene}: 0:0x0002442C
ERROR module{name=sora_scene}: 0:0x00024BA0
ERROR module{name=sora_scene}: 0:0x00032C3C
ERROR module{name=sora_scene}: 0:0x00036990
ERROR module{name=sora_scene}: 0:0x0003B16C
ERROR module{name=sora_scene}: 0:0x0003C26C
ERROR module{name=sora_scene}: 0:0x0003CFC8
Failed: While loading object 'main.dol'

Caused by:
Overlapping functions 3:0x802F7728-3:0x802F7910 -> 3:0x802F7ninja: error: rebuilding 'build.ninja': subcommand failed
744

Feature: Put offsets next to .obj in their data sections.

I have to add these little tags to track these areas:

	.4byte 0x4C4C2069
	.4byte 0x6E202564
	.2byte 0x0A00
.endobj "@633"
	.2byte 0x0000

.obj "@634", local @ C44
	.4byte 0x4F534368
	.4byte 0x65636B41
	.4byte 0x63746976
	.4byte 0x65546872
	.4byte 0x65616473
	.4byte 0x3A204661
	.4byte 0x696C6564
	.4byte 0x20436865
	.4byte 0x636B5468
	.4byte 0x72656164
	.4byte 0x51756575
	.4byte 0x65287468
	.4byte 0x72656164
	.4byte 0x2D3E7175
	.4byte 0x65756529
	.4byte 0x20696E20
	.4byte 0x25640A00
.endobj "@634"

.obj "@635", local @ C88
	.4byte 0x4F534368
	.4byte 0x65636B41
	.4byte 0x63746976

The @ xxx areas would be nice if automatically emitted by DTK. It makes string lookup awful as I have to make sure I grab the right data for each symbol im adding to my WIP code.

[BUG] dwarf dump does not understand anonymous unions.

Repository URL

No response

Game Name

Spongebob Squarepants: Creature from the Krusty Krab

Game Version

USA V0

Description

When I run dwarf dump the structures are not populated correctly. Instead of being able to parse the struct, they get hit by and anonymous union at the tail end of it.

I did a simple fix by changing src/util/dwarf.rs line 1838 and changing it from let name = name.ok_or_else(|| anyhow!("Member without name: {:?}", tag))?; to let name = name.unwrap_or("".to_string());

I don't think that is a good fix but it did it for me. I think there might need to be a more specific fix for this.

Fail to split dol when symbols are applied

dtk fails to split all versions Inazuma Eleven Strikers when symbols are applied.

With symbols_known turned off the analyzer doesn't seem to know these functions are local

Failed: While loading object 'main.dol'

Caused by:
    Multiple symbols with name longlong2str: 11989 Function 0x801E7D10 and 12018 Function 0x801EAC5C

Enabling symbols_known causes a cyclic dependency error (also on local functions it seems)

Failed: While processing object 'main.dol' (module ID 0)

Caused by:
    Cyclic dependency (involving auto_load_match_tex__Fv_text) encountered while resolving link order

repo can be found here

`elf disasm` fails at ELF entry address

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

Failure to locate _rom_copy_info due to duplicate prologue

Had this happen on multiple dols (eg Wrath of Cortex (GC)), when running dtk dol info sys/main.dol

 WARN Failed to locate _rom_copy_info    
Failed: While processing 1:0x800C4E74: FunctionSlices {
    blocks: {
        1:0x800C4E74: Some(
            1:0x800C4EB4,
        ),
        1:0x800C4EB4: None,
        1:0x800C4ED8: Some(
            1:0x800C4F04,
        ),
        1:0x800C4F04: None,
        1:0x800C4F14: Some(
            1:0x800C4F7C,
        ),
        1:0x800C4F7C: None,
        1:0x800C4F8C: Some(
            1:0x800C4FF4,
        ),
        1:0x800C4FF4: None,
        1:0x800C5004: Some(
            1:0x800C506C,
        ),
        1:0x800C506C: None,
        1:0x800C507C: None,
    },
    branches: {
        1:0x800C4EB0: [
            1:0x800C4EB4,
            1:0x800C4ED8,
        ],
        1:0x800C4F00: [
            1:0x800C4F04,
            1:0x800C4F14,
        ],
        1:0x800C4F78: [
            1:0x800C4F7C,
            1:0x800C4F8C,
        ],
        1:0x800C4FF0: [
            1:0x800C4FF4,
            1:0x800C5004,
        ],
        1:0x800C5068: [
            1:0x800C506C,
            1:0x800C507C,
        ],
    },
    function_references: {},
    jump_table_references: {},
    prologue: Some(
        1:0x800C4E74,
    ),
    epilogue: None,
    possible_blocks: {},
    has_conditional_blr: false,
    has_rfi: false,
    finalized: false,
    has_r1_load: false,
}

Caused by:
    Found duplicate prologue: 1:0x800C4E74 and 1:0x800C517C

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.