rickgaiser / neutrino

Small, Fast and Modular PS2 Device Emulator
Academic Free License v3.0
61 stars 3 forks source link

Wrong `_end` on linkfile for `ee_core` binary #23

Closed fjtrujy closed 3 days ago

fjtrujy commented 3 months ago

I think that the definition on the linkfile is wrong: https://github.com/rickgaiser/neutrino/blob/master/ee/ee_core/linkfile#L106-L112

_end points to the end of the available memory region, in this case 0x00097000. I think this is wrong, as _end should point at the moment where the "code ends", otherwise this memory region is going to be wiped by the crt0.s; additionally the _end pointer is used by the SetupHeap, even knowing that ee_core doesn't use heap not sure if something else could be wrong.

Current implementation of linkfile is:

    } >ram84
    _end_bss = .;

    /* Symbols needed by crt0.s.  */
    PROVIDE(_heap_size = -1);
    PROVIDE(_stack = .);
    PROVIDE(_stack_size = 0x00097000 - _stack); /* Any remaining space up to the module storage region, is available for the stack. */

    _end = _stack + _stack_size ;
    PROVIDE(end = _end);

However, I think it should be:

    } >ram84
    _end_bss = .;

    _end = . ;
    PROVIDE(end = .);

    /* Symbols needed by crt0.c.  */
    PROVIDE(_stack = .);
    PROVIDE(_stack_size = 0x00097000 - _stack);
    PROVIDE(_heap_size = -1);

The same code is on OPL, but I wanted to raise the issue first here, as I think it is easy to track/test.

Cheers.

10522 commented 2 months ago

@AKuHAK, @rickgaiser, @uyjulian, @fjtrujy, @israpps, could this issue be due to the fact that USB compatibility has broken since OPL Beta 1.2.0 2078? More details here: 1, 2, 3, 4.

israpps commented 2 months ago

@AKuHAK, @rickgaiser, @uyjulian, @fjtrujy, @israpps, could this issue be due to the fact that USB compatibility has broken since OPL Beta 1.2.0 2078? More details here: 1, 2, 3, 4.

I doubt a linker issue on the EE could have any considerable influence on the OPL core running on the IOP