Closed jendo42 closed 2 years ago
The global object str
needs to have its "global constructor" called. These are special, becouse they are called even before main is called.
The global constructors (and destructors) are called by crt0.o, from here: https://github.com/ps2dev/newlib/blob/ee-v4.1.0/newlib/libc/sys/ps2/crt0.S#L122
Please try the latest toolchain, and also the most simple command line, like:
mips64r5900el-ps2-elf-g++ CPs2TestApp.cpp -o CPs2TestApp.elf
You need to pass -T$(PS2SDK)/ee/startup/linkfile
while linking for the startup code to be linked in.
Yes, the linkfile was missing. Thanks!
I don't know exactly If this is SDK related or toolchain related but I played a little bit around with the SDK and when I used C++ classes I found that the globally defined instances do not get initialized. Check the simple example below:
When I use the
static str
in debugger I can see thatnull
is passed asthis
when callingc_str()
. Otherwise when the string is initialized in the function context it works normally. To me it seems like there is missing some startup code to initialize the static instances. Maybe I forgot something in the build system - I do not use SDK's Makefile rather the premake5 for the project file generation and my build commands are here:I would appreciate if somebody more expirienced will help me with this :)