Thank you for taking a look and pointing me to the code in question. It seems like when -run is used with -nostdlib, the tcc_run() function calls the _start symbol as-if it was a function. Which is not correct as per the x86 64 ABI, not sure about x86 32 ABI. It works with the nostdlib check disabled because it seems to link in runmain.o, which actually calls the main() function of the compiled code, effectivelly negating a part of the -nostdlib flag.
To actually match the behavior of -nostdlib without -run, when using -run, the stack would have to be set up a certain way. You can see what seems to be the x86 64 ABI reference here[1], section 3.4, titled 'Process Initialization'. This possibly could be done with a bit of assembly. Maybe by introducing something like 'lib/runstart.s' that produces 'lib/runstart.o', which would get included in the run program instead of 'runmain.o'. I could probably get that done if it sounds reasonable. But there are a few concerns: - I would have to study the code more to make sure I have a grip of what is going on. - I would have to read the Intel386 ABI to make sure I would not be breaking anything on that end. - I would need to check how -run behaves on Windows, both 32 bit and 64, to be sure I would not break anything there. - I do not have much experience with assembly, and could screw it up. I suppose I will take a look with due dilligence, and maybe just throw it on the mob branch. To see if it sticks or someone yells at me. [1] https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
