ethteck / splat

A binary splitting tool to assist with decompilation and modding projects
MIT License
170 stars 43 forks source link

`ld_align_segment_start` does not work properly when used together with `follows_vram` #385

Open AngheloAlf opened 4 months ago

AngheloAlf commented 4 months ago

The alignment directive is emitted, but then the segment still uses the end vram of the follows_vram segment instead of using the aligned vram.

For example with the given input

  - name: more_funcs
    dir: more_funcs
    type: code
    start: 0x5BF20
    vram: 0x800BF080
    bss_size: 0x1F6F0
    follows_vram: app_render
    ld_align_segment_start: 0x40

The generated linker script says

    }
    __romPos += SIZEOF(.app_render);
    __romPos = ALIGN(__romPos, 16);
    . = ALIGN(., 16);
    app_render_ROM_END = __romPos;
    app_render_VRAM_END = .;

    __romPos = ALIGN(__romPos, 0x40);
    _ = ALIGN(., 0x40);
    more_funcs_ROM_START = __romPos;
    more_funcs_VRAM = ADDR(.more_funcs);
    .more_funcs app_render_VRAM_END : AT(more_funcs_ROM_START)
    {

Ideally the .more_funcs app_render_VRAM_END : AT(more_funcs_ROM_START) line wouldn't use the app_render_VRAM_END, but instead it would use the ALIGNed address.

Also I just noted the wrong _ = ALIGN(., 0x40);. It should be . = ALIGN(., 0x40);