Skip to content

Commit

Permalink
emit_subalign option (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck authored Sep 11, 2024
1 parent fb5a988 commit dbac842
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# splat Release Notes

### 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).

### 0.27.1

* Add new symbol attributes:
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.1,<1.0.0
splat64[mips]>=0.27.2,<1.0.0
```

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


### emit_subalign

Controls whether the `SUBALIGN` directive can be emitted in generated linker scripts. Enabled 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.


### auto_link_sections

A list of linker sections for which entries will be automatically added to the linker script. If a segment contains 10 "c" subsegments, one can rely on this feature to automatically create linker entries for these files in the specified sections. This feature reduces the need to manually add lines to your yaml which only would serve to add linker entries for common sections, such as .data, .rodata, and .bss.
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.1"
version = "0.27.2"
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.1"
__version__ = "0.27.2"
__author__ = "ethteck"

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

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

self._writeln(line)
Expand Down
3 changes: 3 additions & 0 deletions src/splat/util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +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
# 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 @@ -433,6 +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),
auto_link_sections=p.parse_opt(
"auto_link_sections", list, [".data", ".rodata", ".bss"]
),
Expand Down

0 comments on commit dbac842

Please sign in to comment.