mirror of
https://github.com/zeldaret/ph
synced 2026-06-22 16:23:05 -04:00
Add info on decomping static initializers
This commit is contained in:
+22
-1
@@ -3,6 +3,7 @@ This document describes how you can start decompiling code and contribute to the
|
||||
stuck or need assistance.
|
||||
- [Pick a source file](#pick-a-source-file)
|
||||
- [Decompiling a function](#decompiling-a-function)
|
||||
- [Decompiling `.init` functions](#decompiling-init-functions)
|
||||
- [The Ghidra project](#the-ghidra-project)
|
||||
|
||||
## Pick a source file
|
||||
@@ -49,7 +50,27 @@ _0211bf50: .word data_ov09_0211f59c
|
||||
- In the worst case, you can also contribute [non-matching functions](/CONTRIBUTING.md#non-matching-functions) to this
|
||||
project.
|
||||
|
||||
## Decompiling `.init` functions
|
||||
> [!NOTE]
|
||||
> This section will be updated as we learn more about global objects. Feel free to contribute or provide us with more
|
||||
> information!
|
||||
|
||||
Functions in the `.init` section are static initializers. Their purpose is to call C++ constructors on global objects, and to
|
||||
register destructors so the global objects can be destroyed when their overlay unloads.
|
||||
|
||||
Static initializers are generated implicitly and do not require us to write any code ourselves. So, to generate one, you must
|
||||
define a global variable by using a constructor.
|
||||
|
||||
If the static initializer calls `__register_global_object`, that means the global object has a destructor. This means you'll
|
||||
have to declare a destructor if it doesn't exist already.
|
||||
|
||||
Another consequence of having a destructor is that a `DestructorChain` object will be added to the `.bss` section. This struct
|
||||
is 12 (`0xc`) bytes long and is also implicit, so we don't need to define it ourselves.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> An important thing to keep in mind is that a static initializer can construct multiple global objects.
|
||||
|
||||
## The Ghidra project
|
||||
We use a shared Ghidra project to analyze the game and decompile functions. To gain access to the project, install
|
||||
[Ghidra version 10.2.3](https://github.com/NationalSecurityAgency/ghidra/releases/tag/Ghidra_10.2.3_build) and request access
|
||||
from @aetias on Discord.
|
||||
from @aetias on Discord.
|
||||
|
||||
Reference in New Issue
Block a user