pspdev / psplinkusb

General purpose homebrew/debugging toolkit for PSP
https://pspdev.github.io/debugging.html
BSD 3-Clause "New" or "Revised" License
64 stars 35 forks source link

Fix `_exit` issue #52

Closed fjtrujy closed 4 months ago

fjtrujy commented 4 months ago

Description

This PR is required after improving exit flow in pspsdk https://github.com/pspdev/pspsdk/pull/222

The reason why now is this required is because _exit definition has been moved to crt0 and crt0_prx files. In theory, this is totally right, however, the bootstrap module being used here, is quite messy. When generating a prx if you define the function module_start the whole ctr0_prx will be skipped, then the boostrap module uses some functions from newlib, and these functions from newlib ends needing _exit, which wasn't included because crt0_prx was skipped.

I'm not sure if we should move _end out of the crt0 and crt0_prx, I don't think so, however, I'm pretty sure that the issue we are suffering is an edge case, so I think we shouldn't worry that much for now...

Cheers.

sharkwouter commented 4 months ago

Wouldn't it be possible to run ctr0 or rename the module_start? I'd expect more prx files to run into this issue.

fjtrujy commented 4 months ago

Wouldn't it be possible to run ctr0 or rename the module_start? I'd expect more prx files to run into this issue.

We shouldn’t suffer this issue that “often”. Usually when creating PRX there 2 approaches, either you create it without any additional change (as you do it when you want to debug in pspslinkusb), or you generate super tiny PRXs that don’t use any additional custom library (as all the remaining PRXs we have inside of “psplinusb”). However, with this PRX we aren’t doing none of them, and this is actually dangerous as we may face unexpected issues, it uses newlib functions (this is why termínate is being used) without the proper libcglue init steps, it works just by chance.

Said that I still think that we should keep _exit where it is, you as a user will face this “strange” compilation issue as a kind of warning, saying something strange is going on… Additionally, to move it to a different place will force you to have it in one the standards files/libs. Previously it was part of “libcglue” which IMO is also wrong