35 Commits

Author SHA1 Message Date
c3f3ea58e8 Support block_relocations and add_relocations in config.yml
This allows more granular control over generated relocations.

Also optimizes relocation address validity checks,
leading to ~20% faster relocation analysis.

Config example:
```
block_relocations:
# Block any relocation pointing to this address.
- target: .data:0x80130140
# Block any relocation originating from this address.
- source: .text:0x80047160
  # (optional) End address to make it a range.
  end: .text:0x800471A8

add_relocations:
# Inserts or overwrites a relocation.
# From: `subi r3, r3, 0x7657`
# To: `li r3, mesWInsert-0x1@sda21`
- source: .text:0x800473F4
  type: sda21
  target: mesWInsert
  addend: -1
```

Resolves #33
Resolves #52
2024-05-19 22:49:40 -06:00
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
fdafe59e13 Adds data:int and data:short for asm output
Fixes #41
2024-04-30 18:03:45 -06:00
989293a477 Add Yay0/Yaz0 compression & decompression
Uses orthrus-ncompress

Fixes #6
2024-04-30 18:03:00 -06:00
ccfbfd1a5a Fix for jumptable naming in RELs 2024-04-03 00:12:46 -06:00
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
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
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
5c22c8850e Support .BINARY section
Resolves #12
2023-11-29 18:14:48 -05:00
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
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
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
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
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
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
a2374e4fa0 Semi-working REL analysis & splitting 2023-08-23 23:13:12 -04:00
3f63f1ef47 A lot more section-address-aware refactoring 2023-08-23 23:13:12 -04:00
5843ee021e Begin REL analysis & rework lots of code to be section-address aware 2023-08-17 22:09:45 -04:00
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
98ab89a1de Don't relocate against linker symbols for certain relocations 2023-08-10 00:02:28 -04:00
457ee10a42 Emit FORCEACTIVE in LCF & various fixes 2023-08-09 01:24:23 -04:00
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
5bdffa94c4 Generated TU name adjustments 2023-08-08 01:54:01 -04:00
40786587e3 Support common BSS in update_splits & resolve_link_order 2023-08-07 20:05:57 -04:00
9684701d5b Include common symbols in ObjSymbols::for_range 2023-08-07 20:05:00 -04:00
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
b9fd6e077a Remove more unused imports 2023-08-03 19:24:47 -04:00
4ee63abea4 Mark autogenerated splits & rework ObjInfo::add_split 2023-08-03 19:18:20 -04:00
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
8f461b8e0a Add & use ObjSymbolFlagSet helper functions 2023-08-03 19:00:10 -04:00
bd0422e92a Migrate argh to argp, topological-sort to petgraph 2023-08-03 18:57:08 -04:00
0fa0aafaea 6 months of occasional work I guess 2023-07-21 17:59:07 -04:00
36e609eab7 Adjust extern relocation warning 2023-01-28 00:18:39 -05:00
4359ec1fa3 Only warn on extabindex relocations 2023-01-27 23:44:06 -05:00
830f7b172f Reorganize files; start RSO support; config & split updates 2023-01-27 23:15:52 -05:00