Commit Graph

183 Commits

Author SHA1 Message Date
Luke Street c45f37eb10 Update ppc750cl (10x faster!) & upgrade deps 2024-04-30 20:40:14 -06:00
Luke Street c1c4373e53 Prefer references to `_savegpr_14` over `__savegpr`
Same for `__restore_gpr`, `__save_fpr` and `__restore_fpr`.
A common issue that can be solved with a little bit
of special-casing.
2024-04-30 18:04:50 -06:00
Luke Street dc7e307c44 Rework section alignment handling
- 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

Fixes #27
2024-04-30 18:04:17 -06:00
Luke Street dac2dcfc9e Explicitly check split end >= start
Fixes #48
2024-04-30 18:03:59 -06:00
Luke Street fdafe59e13 Adds `data:int` and `data:short` for asm output
Fixes #41
2024-04-30 18:03:45 -06:00
Luke Street bfa926ebbf Write object address and size in asm comments
Fixes #37
2024-04-30 18:03:31 -06:00
Luke Street 989293a477 Add Yay0/Yaz0 compression & decompression
Uses orthrus-ncompress

Fixes #6
2024-04-30 18:03:00 -06:00
Luke Street a156c3697f Appease clippy 2024-04-03 00:18:16 -06:00
Luke Street d0f39f1d82 Support global labels in REL creation (_savegpr, etc) 2024-04-03 00:13:15 -06:00
Luke Street ccfbfd1a5a Fix for jumptable naming in RELs 2024-04-03 00:12:46 -06:00
Luke Street e9a9ed0453 Fixes for switch analysis
- When finalizing a block, restart analysis at
  the first block
- Check for default case in jump table entries
2024-04-03 00:11:58 -06:00
Luke Street 7fd039722d Format & use syntect regex-fancy
The onig crate no longer builds
in CI with cargo-zigbuild.
2024-03-13 18:30:15 -06:00
Luke Street d727110262 Update all dependencies & support new demangle flag
- Support `--mw-extensions` flag for demangle
- Fix relocation handling for object crate upgrade
2024-03-13 18:23:09 -06:00
Luke Street b829e15438 Rework .splitmeta, now .note.split
Uses actual ELF .note format, which is
more standard and handled better by mwld.
2024-03-04 18:12:20 -07:00
Luke Street 96b13be11d Allow overriding jump table size analysis
When the analyzer detects a jump table,
it will now check for an existing object
symbol at that address, using that size
if present.
2024-03-04 18:11:31 -07:00
Luke Street 4f8a9e6fab Write .splitmeta section in split objects
This enables showing the original address of
symbols in objdiff, as well as `elf disasm`
on split objects retaining the original
addresses.
2024-02-28 22:27:38 -07:00
Robin Avery a94edb573f
Emit an error code when `dol diff` does not match (#43)
* Emit an error code when `dol diff` does not match

* `exit(1)` instead of `bail`
2024-02-28 19:18:58 -07:00
Chippy 807dc6a440
Rename and output GCC extensions (#40)
Outputs GCC Source Info extensions
Add asm language to support DWARF emitted by MWCC MIPS assembler
Update MwOverlayBranch handling
2024-02-20 20:56:49 -07:00
1superchip 2784859c4f
Handle more CompileUnit attributes in DWARF (#38)
* Handle more DWARF CompileUnit attributes

Handle comp_dir and add two unknown attributes

* Remove comment about unknown attributes
2024-02-19 16:13:35 -07:00
Luke Street 9a6cb70ff8 Add `ar extract` command 2024-02-09 15:00:09 -07:00
Luke Street 4a84975648 dol apply: Don't apply gap symbols
Also don't overwrite "unknown" scope
with global.

Fixes #30
2024-01-24 23:23:05 -07:00
Luke Street 26cc6a13b4 shasum: Support `-o` in hash mode
Fixes #32
2024-01-24 23:21:55 -07:00
Luke Street f71931838c Sanitize '$' in split filenames
Fixes #29
2024-01-24 23:08:45 -07:00
Luke Street 7b7c8ce251 Add `noexport` attr to symbols.txt
Rename `auto_force_active` to `export_all`.
This is a better solution to code_merging, as
individual functions can be marked `noexport`.
2024-01-14 13:58:18 -07:00
Luke Street 968f50ebed Add `auto_force_active` option (disable to support `-code_merging`)
Fixes #13
2024-01-13 21:54:10 -07:00
Benjamin Moir 5a3256b2b6
Infer anonymous unions from type layout (#26)
* Infer anonymous unions from type layout

* Add comments to signify inferred types

* Improve union detection

* Fix some output weirdness

* Handle some more anonymous union edge cases

* Change union offset validation

* Skip anonymous unions with less than 2 members.
2024-01-13 21:42:39 -07:00
Benjamin Moir 9f8c55efe9
Support anonymous type names as seen in PS2 DWARF (#25) 2024-01-07 08:36:34 -07:00
Benjamin Moir 6b59c677d4
Add support for MwOverlayBranch (#24)
* Add support for MwOverlayBranch

* Make clippy happy

* cargo fmt
2024-01-07 08:02:01 -07:00
Luke Street 59fe8069f8 Analyzer fix for fallthrough switch cases
Fixes #23
2024-01-06 22:57:41 -07:00
Luke Street 58b6d7c7d5 Avoid duplicate unit names when auto-splitting
Fixes #20
2024-01-06 21:57:42 -07:00
Luke Street 85e044463e Support matching multiple symbols with signatures
Half of #20
2024-01-06 18:31:33 -07:00
Luke Street 458d0599f5 dwarf dump: Emit address range for compile units and functions 2024-01-06 17:51:09 -07:00
Luke Street d9612cc9b7 Analyzer improvements for ProDG (WIP)
Fixes #19
2024-01-06 16:05:04 -07:00
Luke Street c44846d73f Allow absolute relocations to linker generated symbols
Fixes #15
2024-01-06 11:47:17 -07:00
Luke Street 8e7de9588f cargo fmt 2024-01-06 10:29:51 -07:00
Luke Street 3bcfaef4fe Zero out relocations before disassembling
Fixes an issue where an addi with relocation
can be disassembled as subi
2024-01-06 10:28:01 -07:00
Benjamin Moir dd23fef4f7
Support some more MetroWerkz DWARF extensions (#22)
* Support FT_MW_int128

* Support OP_MW_FPREG

* Support AT_MW_mangled on local variables

* cargo fmt

---------

Co-authored-by: Luke Street <luke@street.dev>
2024-01-02 10:33:07 -07:00
Luke Street d470f7aec6 Version 0.6.5 2023-12-20 20:30:48 -07:00
Luke Street 227153193e Sanitize auto-function-split names
Fixes #16
2023-12-20 20:28:30 -07:00
Luke Street 2681e51443 Don't double remove obj path extension
Don't remember why I had it like this

Fixes #17
2023-12-20 20:22:00 -07:00
Luke Street 6f2bb62082 Downgrade vis_flags/active_flags error to warn
Fixes #18
2023-12-20 19:11:23 -07:00
Sewer d43b95a0e4
Added: Support for Little Endian DWARF, Inline Arrays & Additional MetroWerks Extensions (#14)
* Added: Minimal Required Changes to Dump Sonic Heroes (PS2)

* Added: Switch for Little Endian DWARF Dump

* Added: Support for Array Ordering

* Added: Big/Little Endian Variants of u32_from_bytes

* Changed: Detect bitness from .elf header.

* Changed: Use Proper MetroWerks Names

* Changed: Use Endianness from File API

* Refactor DWARF endian handling & some fixes

* Undo accidental formatting changes

---------

Co-authored-by: Luke Street <luke@street.dev>
2023-12-11 13:07:29 -05:00
Luke Street 0cfc5df20b Overhauled common BSS support & more
- With a map, attempts to detect and handle common BSS automatically
- With a map, attempts to detect and correct inflated common BSS bug (< GC 2.7 linker)
- Support for "stripped" symbols, sometimes required to match inflated common BSS sizes
- Warns on duplicated TUs in a map (other than common BSS)
- Automatically adds `comment:0` to `.s` TUs from a map (avoids linker crash)
2023-11-29 18:31:35 -05:00
Luke Street 5c22c8850e Support `.BINARY` section
Resolves #12
2023-11-29 18:14:48 -05:00
Luke Street 4cb6f4f85d dwarf dump: Better support for GCC/ProDG & various fixes
- Displays subroutine "static" and "inline" if present
- Displays subroutine labels, blocks and inlines if present
- Displays struct member visibility if present
- Skips tags that can't be processed rather than bailing
2023-11-27 16:35:12 -05:00
Luke Street 5128ff67b2 bin2c: Honor symbol alignment 2023-11-26 01:12:34 -05:00
Luke Street dd60128ba0 Extract embedded assets to binary and C header
Adds an "extract" list to project configuration:
```
extract:
- symbol: SomeData
  binary: Lib/SomeData.bin
  header: Lib/SomeData.inc
```
This example extracts the data of symbol
`SomeData` to `out_dir/bin/Lib/SomeData.bin`,
and a C array representation to
`out_dir/include/Lib/SomeData.inc`.

Resolves #11
2023-11-26 00:35:05 -05:00
Luke Street e3d6ef8492 dwarf dump: Fix padding handling within tag children
Fixes #9
2023-11-22 12:59:03 -05:00
Luke Street c8a2d4896a dwarf dump: Fix reversed struct/class in def
Fixes #10
2023-11-22 12:21:24 -05:00
Luke Street ebff47924f Add `links` field to config for overriding REL linkage
By default, every REL is linked with every other REL. Some games, like Mario Party, link RELs individually, so the module IDs are not unique. To support this, the `links` field can be used to override which _other_ modules are included in a module's analysis.
2023-11-18 23:37:50 -05:00
Luke Street 28af4872ab rel make: Add `--quiet`/`-q`, `--names`/`-n` args
`-n` is a somewhat ugly hack to only select certain modules from `config.yml`, for games with overlapping module IDs
2023-11-18 23:34:44 -05:00
Luke Street 38c692650f write_rel: Skip setting reloc/imp offset with empty relocations 2023-11-18 23:33:18 -05:00
Luke Street 8659b56da4 Skip writing objects and ldscripts if unchanged
Avoids unnecessary rebuilds with build systems like ninja & make that track mtime
2023-11-18 17:21:08 -05:00
Luke Street 363fa2ac72 Use custom syntect packs to reduce binary size
- Custom syntax set containing only C/C++
- Custom themeset containing only Solarized (Dark)
- Disable default syntect features
2023-11-18 16:12:03 -05:00
Luke Street 8f559c8921 Update dependencies & CI changes
- Use separate release-lto profile for CI
- A couple of clippy fixes
2023-11-18 15:03:24 -05:00
Luke Street 5e13998e93 Major `dwarf dump` rework
- Supports games with C++ DWARF info
- Syntax highlighting when printing to console (disable with `--no-color`)
- Overall improvements to parsing and output
2023-11-18 13:56:58 -05:00
Luke Street 4935708b61 Fix REL v2 creation (and v1, hopefully)
- Adjusts `write_rel` to use the proper ordering for relocations and imports based on the REL version.
- Adds `-r`/`--relocations` switch to `rel info` that prints (very) verbose relocation information.
2023-11-09 01:16:37 -05:00
Luke Street ec4caf5000 Smarter configuration updates
- Avoid overwriting `symbols.txt` or `splits.txt` if the file was modified since it was read or if the file's contents didn't change.
- Remove `binrw` and `byteorder` dependencies, moving to `FromReader`/`ToWriter` traits.
- Migrate generic bounds to `where` clauses.
- Remove unused `build.rs` logic.
2023-11-07 23:21:59 -05:00
Luke Street 41a69441da Support section 241 (extabindex) in RSOs 2023-10-10 12:32:56 -04:00
Luke Street 95c779b105 Better terminal color support
- Enables ANSI on Windows 10
- Disables colors if unsupported
- Supports `--no-color` and env `NO_COLOR` to disable
- Supports env `FORCE_COLOR` and `CLICOLOR_FORCE` to enable
2023-10-10 12:32:05 -04:00
Luke Street a164852a15 Write gap symbols as hidden 2023-10-07 14:50:01 -04:00
Luke Street dfb569b883 Add alf support (NVIDIA Shield TV binaries)
- Supports .alf files in all places .dol files are accepted.
- Adds `hash` and `dhash` to symbols config.
2023-10-07 02:03:09 -04:00
Luke Street 36bb5ddcc6 Zero out section data for relocations in relocatable ELFs
Fixes issues with Wii versions of mwld.
2023-10-01 12:50:21 -04:00
Luke Street c354c6da4b REL section alignment fixes
- Honor section alignment from splits.txt when writing RELs
- Better heuristic for determining REL section alignment on initial analysis
2023-09-26 13:06:57 -04:00
Luke Street 610a2e56b9 Add `ldscript_template` option to project config 2023-09-23 07:56:49 -04:00
Luke Street 400fb7fa7f Add `code_size`, `data_size` to generated `config.json`
Also simplify project config generation by skipping default fields
2023-09-14 17:24:00 -04:00
Luke Street 59a4eb33d0 Write `version` in generated `config.json` 2023-09-13 17:07:06 -04:00
Luke Street 42217a339e Update cargo deny.toml 2023-09-13 02:10:47 -04:00
Luke Street d4ef1ce16a Analyzer fixes galore
- Transparent NLZSS decompression (add `:nlzss` to path)
- Overhaul portions of the analyzer to support more games
- Reject some invalid data relocations automatically
- Jump table analysis fixes
2023-09-13 02:08:51 -04:00
Luke Street 50f913c4eb clippy fixes 2023-09-10 02:20:54 -04:00
Luke Street 18170a96a2 Don't use map in `dol diff` and `dol apply`; remove common BSS hack 2023-09-10 02:20:08 -04:00
Luke Street 788ffb9e17 Fix empty .lcf FORCEACTIVE with symbols_known 2023-09-09 19:24:13 -04:00
Luke Street 6abe6cc277 clippy fix 2023-09-05 17:31:19 -04:00
Luke Street e3857d3212 Improvements to REL & map support
- Fix symbols.txt align attribute
- Fully support nested RARC files & transparent Yaz0 decompression
- Guess symbol visibility for maps without link map
- Add module name config
- Add manual force_active config
- Quiet option for shasum
- `symbols_known` and `fill_gaps` config
- Allow disabling .comment generation per-unit (`comment:0`)
- Various minor fixes
- Add `rarc` and `yaz0` commands
2023-09-05 17:22:22 -04:00
Luke Street f9f7fb2e1e Working `rel make` & more
- Added `elf info`
- Improved `rel info`
- Colored output for `shasum`
- Fix section `rename` in RELs
- Added padding symbols to avoid linker issues
- Automatically set symbols to "active" in .comment output
2023-08-23 23:13:12 -04:00
Luke Street a2374e4fa0 Semi-working REL analysis & splitting 2023-08-23 23:13:12 -04:00
Luke Street 3f63f1ef47 A lot more section-address-aware refactoring 2023-08-23 23:13:12 -04:00
Luke Street 5843ee021e Begin REL analysis & rework lots of code to be section-address aware 2023-08-17 22:09:45 -04:00
Luke Street 933edcfb19 Clippy fixes 2023-08-15 22:47:35 -04:00
Luke Street 23a156a6d5 Add selfile option & load in `dol split` 2023-08-15 22:45:23 -04:00
Luke Street 908e3bb037 Check functions at start of code sections in detect_functions 2023-08-15 22:44:48 -04:00
Luke Street a394dfc88c Improved sanity checks in asm write_data 2023-08-15 22:44:06 -04:00
Luke Street 2c2ee8bf08 Validate splits don't overlap symbols (or each other)
Use DoubleEndedIterator::next_back instead of Iterator::last to avoid unnecessary iteration.
2023-08-15 09:47:00 -04:00
Luke Street d272b5dce8 Write common symbol align in asm 2023-08-15 09:36:45 -04:00
Luke Street 522909907c Add quick_analysis option & disable auto_force_files by default 2023-08-10 00:05:33 -04:00
Luke Street 33a026d0c7 Support module hash in config.yml 2023-08-10 00:04:35 -04:00
Luke Street 5272f90991 Read symbol alignment from .comment 2023-08-10 00:03:44 -04:00
Luke Street 265e26ee40 Guess section alignment & write __ArenaHi in .lcf 2023-08-10 00:03:14 -04:00
Luke Street 98ab89a1de Don't relocate against linker symbols for certain relocations 2023-08-10 00:02:28 -04:00
Luke Street cf328b8707 Only create relocations for direct branches 2023-08-09 23:59:26 -04:00
Luke Street 457ee10a42 Emit FORCEACTIVE in LCF & various fixes 2023-08-09 01:24:23 -04:00
Luke Street d9e1ae2777 MW 2.7 LD compatibility fixes & more
- More robust .comment section handling
- Auto-create .comment section for objects with common symbols (MW 2.7+ hack)
- Support loading REL modules in `dol split` (currently only for references)
- Add `dol diff` for quick diffing between linked ELF and expected symbols
- Add `dol apply` for applying linked ELF symbols to symbol config file
2023-08-08 23:34:00 -04:00
Luke Street 5bdffa94c4 Generated TU name adjustments 2023-08-08 01:54:01 -04:00
Luke Street 46801939a3 Fix up .comment section writing & support symbol force_active 2023-08-08 01:53:47 -04:00
Luke Street 40786587e3 Support common BSS in update_splits & resolve_link_order 2023-08-07 20:05:57 -04:00
Luke Street c9eb824034 Emit __init_cpp_exceptions_reference symbols as global 2023-08-07 20:05:19 -04:00
Luke Street 9684701d5b Include common symbols in ObjSymbols::for_range 2023-08-07 20:05:00 -04:00
Luke Street e215b6d843 Fix write_elf for common symbols & only write filename in file symbol 2023-08-07 20:04:40 -04:00
Luke Street e802b61001 Fix autogenerated unit output in config.json 2023-08-07 20:03:58 -04:00
Luke Street c07826e57f Output common/rename in write_split 2023-08-07 20:03:34 -04:00