Skip to content

Commit

Permalink
subalign_override
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck committed Sep 11, 2024
1 parent dbac842 commit 17b62d0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# splat Release Notes

### 0.27.3
* Added new global option `subalign_override`. If set, overrides the subalign of all segments to the specified value. Unset by default (no change in default behavior).
* Removed global option `emit subalign`. Shiftability problems are great.

### 0.27.2
* Added new global option `emit_subalign`. If disabled, subalign directives will not be emitted in the generated linker script. Enabled by default (no change in default behavior).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The brackets corresponds to the optional dependencies to install while installin
If you use a `requirements.txt` file in your repository, then you can add this library with the following line:

```txt
splat64[mips]>=0.27.2,<1.0.0
splat64[mips]>=0.27.3,<1.0.0
```

### Optional dependencies
Expand Down
6 changes: 3 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ subalign: 4
`16`


### emit_subalign
### subalign_override

Controls whether the `SUBALIGN` directive can be emitted in generated linker scripts. Enabled by default.
Overrides the `SUBALIGN` value for all segments. `null` by default.

This parameter was added as a way to override standard behavior with multiple yamls.
The base project yaml may need to use subalign for matching purposes, but shiftable builds might not want such a linker script.
The base project yaml may need to use subalign for matching purposes, but shiftable builds might need a different subalign value.


### auto_link_sections
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "splat64"
# Should be synced with src/splat/__init__.py
version = "0.27.2"
version = "0.27.3"
description = "A binary splitting tool to assist with decompilation and modding projects"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
2 changes: 1 addition & 1 deletion src/splat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__package_name__ = __name__

# Should be synced with pyproject.toml
__version__ = "0.27.2"
__version__ = "0.27.3"
__author__ = "ethteck"

from . import util as util
Expand Down
8 changes: 6 additions & 2 deletions src/splat/segtypes/linker_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ def _begin_segment(
if not noload:
seg_rom_start = get_segment_rom_start(seg_name)
line += f" AT({seg_rom_start})"
if options.opts.emit_subalign and segment.subalign != None:
if options.opts.subalign_override is not None:
line += f" SUBALIGN({options.opts.subalign_override})"
elif segment.subalign != None:
line += f" SUBALIGN({segment.subalign})"

self._writeln(line)
Expand Down Expand Up @@ -634,7 +636,9 @@ def _begin_partial_segment(self, section_name: str, segment: Segment, noload: bo
if noload:
line += " (NOLOAD)"
line += " :"
if options.opts.emit_subalign and segment.subalign != None:
if options.opts.subalign_override is not None:
line += f" SUBALIGN({options.opts.subalign_override})"
elif segment.subalign != None:
line += f" SUBALIGN({segment.subalign})"

self._writeln(line)
Expand Down
6 changes: 3 additions & 3 deletions src/splat/util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class SplatOpts:
# Linker script
# Determines the default subalign value to be specified in the generated linker script
subalign: Optional[int]
# Determines whether to emit the subalign directive in the generated linker script
emit_subalign: bool
# An optional override value for all segments' subalign values
subalign_override: Optional[int]
# The following option determines a list of sections for which automatic linker script entries should be added
auto_link_sections: List[str]
# Determines the desired path to the linker script that splat will generate
Expand Down Expand Up @@ -435,7 +435,7 @@ def parse_endianness() -> Literal["big", "little"]:
lib_path=p.parse_path(base_path, "lib_path", "lib"),
elf_section_list_path=p.parse_optional_path(base_path, "elf_section_list_path"),
subalign=p.parse_optional_opt_with_default("subalign", int, 16),
emit_subalign=p.parse_opt("emit_subalign", bool, True),
subalign_override=p.parse_optional_opt("subalign_override", int),
auto_link_sections=p.parse_opt(
"auto_link_sections", list, [".data", ".rodata", ".bss"]
),
Expand Down

0 comments on commit 17b62d0

Please sign in to comment.