CUtil Makefile
Julie Stamp (8365) 474 posts |
I’m having a go at making a Utility in C, and I’ve got a hello world, with this Makefile
c.main
It links a utility, but when runs says “Trap in trap handler…”. I might be able to do without stdlib, so I tried getting rid of ANSILib by putting
after the include CUtil, but it then fails to link saying symbol __main is undefined (I tried putting that as a function but then it says no entry point defined). So: Has someone got a working utility, in C, using CUtil or otherwise that links and runs ok with or without stdlib functions? |
Stuart Swales (1481) 351 posts |
I wouldn’t think that the SharedCLibrary (or AnsiLib for that matter) expects that environment! |
Jeffrey Lee (213) 6048 posts |
I don’t think we have any ready-to-go stubs / “crt0” to allow a “C-only” utility to be written. But, it shouldn’t be too hard to write some minimal stubs that will work with code that doesn’t need the standard library. A (non-exhaustive) search of the sources turns up two uses of the CUtil makefile:
zinflate is an unusual case – it’s the zlib decompression code used for compressed ROM images. So instead of producing a runnable Utility, it produces a position-independent binary which begins with the decompression header described here. But it does give some clues as to what’s necessary for creating an assembler stub that can be used with arbitrary C:
Yeah, you’d have trouble trying to convince either of those to work in a Utility. |
Julie Stamp (8365) 474 posts |
Ok, here’s my working hello world. s.entry
c.main
Makefile
I did zero FP for the benefit of the first stack frame. I didn’t try and pass through the R12 workspace yet, I’ll see how it goes as I write the program — I think the most sensible will be to just make everything local variables since it’s all coming out of that same 1K block anyway. Thanks :-) |
Jeffrey Lee (213) 6048 posts |
Note that |
Julie Stamp (8365) 474 posts |
I’ve had to abandon this idea as I need to start a new application which I’m not allowed to do from a utility, so I’m doing a runnable module instead. It’s nice to know that you can do it though. |