Post by LHBI managed to compile musl libc with pcc. I am wondering about startup
files. musl comes with its own startup object files, so which are the
correct ones?
It will be a combination, since there may be features provided in either
which are required either by the musl libc code, or the pcc generated code
Post by LHBIf anyone is feeling generous they might add the purpose of these files.
What good are they?
they are the code that is run before main() is called and after it returns
or exit() is called, they set up the environment that C code expects (some
of this may be required by the library code, some of it by the compiler
and some by the host :)
for instance..
A musl library function may use a getenv() call to check the runtime
environment (eg malloc sometimes does this) and the musl libc getenv()
function might require a __musl_env pointer to be pre-initialized. The
musl startup could would handle that.
A pcc compiled function in application code may be marked with "#pragma
init" which means that pcc puts the address into an array in a special
section so that the code will be run before main() is called. The pcc
startup code would handle this.
Then, there can be target (both OS & machine) dependencies in the startup
code for processes, exactly how it receives information, exactly how it
must terminate. The host startup code would handle that.
You will probably find though, that if musl libc was designed to be built
by gcc on your system, that the gcc-compat in pcc is enough to let the
musl libc startup code work fine, and you might find also that the pcc
startup code would also work just great.. However, it could be worth
checking to see exactly what the startup code does to verify that there
will be no problems if you want to use it in a production item :)
iain