Skip to content

Commit

Permalink
asm_ehtable_label_macro and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Jul 10, 2024
1 parent 8281073 commit a8e3518
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Two new types of segments: `gcc_except_table` and `eh_frame`.
* Used by GCC to handle C++ exceptions.
* New yaml option: `asm_jtbl_label_macro`
* Allows to specify the macro used by ehlabels, the ones generated by `gcc_except_table` references.

### 0.24.6

Expand Down
6 changes: 6 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ Determines the macro used to declare data symbols in asm files

Determines the macro used at the end of a function, such as endlabel or .end

### asm_ehtable_label_macro

Determines the macro used to declare ehtable labels in asm files.

Defaults to `ehlabel`

### asm_emit_size_directive

Toggles the .size directive emitted by the disassembler
Expand Down
12 changes: 12 additions & 0 deletions docs/Segments.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ By default the generated assembly file will be written relative to the configure
- [0x093D60, databin, rsp/aspMain]
```

## `gcc_except_table`

Used by certain compilers (like GCC) to store the Exception Handler Table (`ehtable`), used for implementing C++ exceptions.

This table contains references to addresses within functions, which normally the disassembler would automatically reject as being valid addresses. This special section bypasses that restriction by generating special labels within the functions in question. The macro used for these labels can be changed with the [`asm_ehtable_label_macro`](Configuration.md#asm_ehtable_label_macro) option.

## `eh_frame`

Used by certain compilers (like GCC) to store the Exception Handler Frame, used for implementing C++ exceptions.

This frame contains more metadata used by exceptions at runtime.

## PS2 exclusive segments

### `lit4`
Expand Down
1 change: 1 addition & 0 deletions src/splat/disassembler/spimdisasm_disassembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def configure(self):
)
spimdisasm.common.GlobalConfig.ASM_DATA_LABEL = options.opts.asm_data_macro
spimdisasm.common.GlobalConfig.ASM_TEXT_END_LABEL = options.opts.asm_end_label
spimdisasm.common.GlobalConfig.ASM_EHTBL_LABEL = options.opts.asm_ehtable_label_macro

if options.opts.asm_emit_size_directive is not None:
spimdisasm.common.GlobalConfig.ASM_EMIT_SIZE_DIRECTIVE = (
Expand Down
1 change: 1 addition & 0 deletions src/splat/util/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Compiler:
asm_jtbl_label_macro: str = "glabel"
asm_data_macro: str = "glabel"
asm_end_label: str = ""
asm_ehtable_label_macro: str = "ehlabel"
c_newline: str = "\n"
asm_inc_header: str = ""
include_macro_inc: bool = True
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 @@ -183,6 +183,8 @@ class SplatOpts:
asm_data_macro: str
# Determines the macro used at the end of a function, such as endlabel or .end
asm_end_label: str
# Determines the macro used to declare data symbols in asm files
asm_ehtable_label_macro: str
# Toggles the .size directive emitted by the disassembler
asm_emit_size_directive: Optional[bool]
# Determines including the macro.inc file on non-migrated rodata variables
Expand Down Expand Up @@ -493,6 +495,7 @@ def parse_endianness() -> Literal["big", "little"]:
),
asm_data_macro=p.parse_opt("asm_data_macro", str, comp.asm_data_macro),
asm_end_label=p.parse_opt("asm_end_label", str, comp.asm_end_label),
asm_ehtable_label_macro=p.parse_opt("asm_ehtable_label_macro", str, comp.asm_ehtable_label_macro),
asm_emit_size_directive=asm_emit_size_directive,
include_macro_inc=p.parse_opt(
"include_macro_inc", bool, comp.include_macro_inc
Expand Down

0 comments on commit a8e3518

Please sign in to comment.