Commit Graph

59 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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 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 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 e802b61001 Fix autogenerated unit output in config.json 2023-08-07 20:03:58 -04:00
Luke Street a046bf9a66 Updates for build system integration
- Use a config file as input to `dol split`
- Add depfile output
- Adjust splits config writing
2023-08-06 15:46:51 -04:00
Luke Street 4b6e317d0b Adjustments for use with ninja build 2023-08-05 20:27:05 -04:00
Luke Street fefe4a36f0 Small dol split output adjustments 2023-08-05 18:35:11 -04:00
Luke Street 636213fdfd Remove unused imports 2023-08-03 19:19:05 -04:00
Luke Street 5c04800964 Run apply_signatures_post appropriately 2023-08-03 19:05:40 -04:00
Luke Street 6723245ed6 dol split: Write units file 2023-08-03 19:05:00 -04:00
Luke Street f06a6ffbdd Ignore ABS symbols in ObjSymbols::for_range
- Add ObjSymbols::iter_ordered for all symbols (including ABS)
- Extract duplicated logic into ObjSymbols::for_relocation
2023-08-03 19:04:17 -04:00
Luke Street bd0422e92a Migrate argh to argp, topological-sort to petgraph 2023-08-03 18:57:08 -04:00
Luke Street 6b81faa5e1 dwarf dump: More register names, fix padding handling 2023-08-02 18:29:03 -04:00
Luke Street 0fa0aafaea 6 months of occasional work I guess 2023-07-21 17:59:07 -04:00
Luke Street f1b4afa885 Add `dwarf dump` cmd 2023-02-14 21:50:23 -05:00