PS3 Custom C Standard Library Implementation for PS3

StarmanX32

Member
I am back from the dead and I've made a project a month ago. This is a custom and open-source implementation of the C Standard Library for the PS3, keep in mind it's not finished yet. So far, I've implemented most of the string.h functions and a small amount of stdio functions.

I assume some people will argue that I shouldn't reinvent the wheel, we got some solutions already (vsh exports, eboot exports) or any different neutral to negative argument against the project. Yes, I'm indeed aware that we already got the VSH exports or EBOOT exports, but keep in mind that these either only work for a specific application (VSH) or are highly limited on their functionality (EBOOT), I could make use of the EBOOT exports tho, adding functions like malloc and free to the std libs. My version's goal is to be universally available for any type of PS3 project and to be fully open-source.

It's mostly based off musl C lib (without the extra GNU specific code) and a few PS3 specific implementations that I've found on some PS3 projects (SPRX Mod Menus, WebMAN MOD and other projects)

If anyone is interested in taking time to further develop the library, I'd greatly appreciate it.

It's being compiled as a static library (.a). and uses PPU GCC. Some developers might understandably ask, if the library wouldn't output linker errors (a known issue with Sony's C and C++ libs for sprx projects), to be extra safe, I've put an underscore before the function name on every function, the user headers (stdio.h, string.h, etc.) then mainly contain defines which remove the underscore, that's my plan.

I honestly wasn't able to test the library, I couldn't find much time to do all that stuff, life's stressing rn.

Here's the link.
https://github.com/PHTNCx64/plibc
 
I am back from the dead and I've made a project a month ago. This is a custom and open-source implementation of the C Standard Library for the PS3, keep in mind it's not finished yet. So far, I've implemented most of the string.h functions and a small amount of stdio functions.

I assume some people will argue that I shouldn't reinvent the wheel, we got some solutions already (vsh exports, eboot exports) or any different neutral to negative argument against the project. Yes, I'm indeed aware that we already got the VSH exports or EBOOT exports, but keep in mind that these either only work for a specific application (VSH) or are highly limited on their functionality (EBOOT), I could make use of the EBOOT exports tho, adding functions like malloc and free to the std libs. My version's goal is to be universally available for any type of PS3 project and to be fully open-source.

It's mostly based off musl C lib (without the extra GNU specific code) and a few PS3 specific implementations that I've found on some PS3 projects (SPRX Mod Menus, WebMAN MOD and other projects)

If anyone is interested in taking time to further develop the library, I'd greatly appreciate it.

It's being compiled as a static library (.a). and uses PPU GCC. Some developers might understandably ask, if the library wouldn't output linker errors (a known issue with Sony's C and C++ libs for sprx projects), to be extra safe, I've put an underscore before the function name on every function, the user headers (stdio.h, string.h, etc.) then mainly contain defines which remove the underscore, that's my plan.

I honestly wasn't able to test the library, I couldn't find much time to do all that stuff, life's stressing rn.

Here's the link.
https://github.com/PHTNCx64/plibc

Thanks for share your project. Aren't these functions already included in psl1ght library or in libstdc_export_stub.a in Sony's SDK?

In webMAN MOD I use the export whenever it's possible to reduce the memory usage.
Only a few std C functions are customized for specific purposes.
 
Last edited:
Thanks for share your project. Aren't these functions already included in psl1ght library or in libstdc_export_stub.a in Sony's SDK?

In webMAN MOD I use the export whenever it's possible to reduce the memory usage.
Only a few std C functions are customized for specific purposes.

The problem with Sony's implementation is, that, for whatever reason, you can't use it in SPRX based projects. It always throws linker errors that the references are undefined. Psl1ght can't compile SPRX if I'm not mistaken, I'm not sure if they rely on Sony's implementation or if it's also open-source and custom made. Also, creating a new c stdlib has the advantage that we can update it whenever we want, improve whenever we want and use it universally on all project types. My version is basically there to provide a uniform, open-source and easy to use standard library without going through the hassle of reimplementing everything yourself or finding the symbols inside external SELF applications.

Also getting the help of other developers would greatly speed up development and everyone pretty much benefits from it.

I need to find a way to implement functions like malloc or free. RouLetteBoi has given me the information, that some functions like these are available within the EBOOT and that we just need to export them, however, I'm not a reverse engineer, so I can't do that myself. Iirc, Cobra has some memory related functions which could lead to implement a custom malloc function. Regarding that, any info would be appreciated.


Gesendet von iPhone mit Tapatalk
 
The problem with Sony's implementation is, that, for whatever reason, you can't use it in SPRX based projects. It always throws linker errors that the references are undefined. Psl1ght can't compile SPRX if I'm not mistaken, I'm not sure if they rely on Sony's implementation or if it's also open-source and custom made. Also, creating a new c stdlib has the advantage that we can update it whenever we want, improve whenever we want and use it universally on all project types. My version is basically there to provide a uniform, open-source and easy to use standard library without going through the hassle of reimplementing everything yourself or finding the symbols inside external SELF applications.

Also getting the help of other developers would greatly speed up development and everyone pretty much benefits from it.

I need to find a way to implement functions like malloc or free. RouLetteBoi has given me the information, that some functions like these are available within the EBOOT and that we just need to export them, however, I'm not a reverse engineer, so I can't do that myself. Iirc, Cobra has some memory related functions which could lead to implement a custom malloc function. Regarding that, any info would be appreciated.


Gesendet von iPhone mit Tapatalk

As I commented above I use in webMAN MOD the exports in libstdc_export_stub.a.
https://github.com/aldostools/webMAN-MOD/blob/master/libc.c#L24-L28

Example for memcpy and strstr:
Code:
extern void *stdc_831D70A5(void *dest, const void *src, size_t num); // memcpy()
void* memcpy(void *dest, const void *src, size_t num) {if(!dest || !src || !num) return NULL; return stdc_831D70A5(dest, src, num);}

extern char *stdc_C5C09834(const char *str1, const char *str2); // strstr()
char* strstr(const char *str1, const char *str2) {if(!str1 || !str2) return NULL; return stdc_C5C09834(str1, str2);}

Probably you forgot to include the stdc_export_stub in the lib folder and the reference in makefile.
https://github.com/aldostools/webMAN-MOD/blob/master/makefile#L21-L38
https://github.com/aldostools/webMAN-MOD/blob/master/lib/libstdc_export_stub.a

Example:
Code:
PPU_PRX_LDLIBS = -lfs_stub -lnet_stub -lrtc_stub -lio_stub -lgcm_sys_stub \
                 -lallocator_export_stub -lstdc_export_stub
 
As I commented above I use in webMAN MOD the exports in libstdc_export_stub.a.
https://github.com/aldostools/webMAN-MOD/blob/master/libc.c#L24-L28

Example for memcpy and strstr:
Code:
extern void *stdc_831D70A5(void *dest, const void *src, size_t num); // memcpy()
void* memcpy(void *dest, const void *src, size_t num) {if(!dest || !src || !num) return NULL; return stdc_831D70A5(dest, src, num);}

extern char *stdc_C5C09834(const char *str1, const char *str2); // strstr()
char* strstr(const char *str1, const char *str2) {if(!str1 || !str2) return NULL; return stdc_C5C09834(str1, str2);}

Probably you forgot to include the stdc_export_stub in the lib folder and the reference in makefile.
https://github.com/aldostools/webMAN-MOD/blob/master/makefile#L21-L38
https://github.com/aldostools/webMAN-MOD/blob/master/lib/libstdc_export_stub.a

Example:
Code:
PPU_PRX_LDLIBS = -lfs_stub -lnet_stub -lrtc_stub -lio_stub -lgcm_sys_stub \
                 -lallocator_export_stub -lstdc_export_stub

I assume the stdc stub in WMM is for the VSH only, is it verified to work on other SELF applications? If yes, my bad. But still, my version can be used on all SPRX project that get loaded by all sorts of SELF application. That's one reason I started this project [emoji28]


Gesendet von iPhone mit Tapatalk
 
I assume the stdc stub in WMM is for the VSH only, is it verified to work on other SELF applications? If yes, my bad. But still, my version can be used on all SPRX project that get loaded by all sorts of SELF application. That's one reason I started this project [emoji28]


Gesendet von iPhone mit Tapatalk
AFAIK the stub lib is for vsh plugins, other sprx projects should not need it as they can use the exports from their own self (the self they're made to work with), for that the libc_stub included in the SDK should do the job fine.
The reason for all this is that no dev was ever meant to write vsh plugins, only s@ny, so they were able to use their own library implementation for vsh.self without including any stubs in the SDK and of course when homebrew writers started to create vsh plugins, someone (mysis?) ended up creating a stub library and headers.

Having said that, having a full libc library at the ready would still be welcome and useful.
 
AFAIK the stub lib is for vsh plugins, other sprx projects should not need it as they can use the exports from their own self (the self they're made to work with), for that the libc_stub included in the SDK should do the job fine.
The reason for all this is that no dev was ever meant to write vsh plugins, only s@ny, so they were able to use their own library implementation for vsh.self without including any stubs in the SDK and of course when homebrew writers started to create vsh plugins, someone (mysis?) ended up creating a stub library and headers.

Having said that, having a full libc library at the ready would still be welcome and useful.

I've made a few progresses. However, I can't really implement functions that do internal calls to malloc right now, there seems to be a syscall 348, which performs a memory allocation and is probably internally called by sony's malloc implementation, it makes the most sense for me. But I can't say what to put in the 2nd parameter flag.. I'm going to test to this next weekend, if anyone already has an answer for that, I'd be happy to know.


Gesendet von iPhone mit Tapatalk
 
try passing a SYS_MEMORY_PAGE_SIZE_64K allocation as the flag for the 2nd parameter as what zar suggested in another thread
 
Back
Top