Hello all,
How can i write a c or c++ program without any runtime library at all.My basic requirement is i will write all the functions myself and the compiler should only produce the code that my source code says.I will not use any function from the runtime library and i will not even include any header.If it could be done using command line swicthes then please let me know about it.I prefer C Compiler.
I would like to make a boot loader like program using either C or C++.With a little or no ASM
1.Which compiler the BIOS making people use.Do they code only in ASM ?.I assume they use both. 2.What compiler the Single board microprocessor trainer people use ?. 3.Is the simulator like Virtual PC).Like the one available for microcontrollers,like IARs,etc which has editor,compiler & simulator all built in. 4.Where can i get the latest Standard call info which is supported by all processors.Who is standardizing the code.
Thanks
Pak
Hi Pak,
it is relatively easy to avoid the C run-time environment. At the end of your startup code do not branch to main. Create your C-entry function yourself, like C_Entry. By not calling main, the C run-time environment is not established, including the heap (there is no heap). Make also sure that you disable semihosting (use_no_semihosting). For the rest of your software you have to provide routines for your fixed point math operations depending on your platform (8 bit will be more complicated than 32 bit). If you need floating point math it will get really complicated, so stay away from it. I did several of such projects for safety critical applications and it works but expect a lot of work in front of you. Good luck!
Frank
F D, I learn something today (from you! ). But of course, I verified you...this is an excerpt from http://www.arm.com:
"Applications which contain a function main() can make stdio semihosting calls (e.g. printf) when linked with an ANSI C semihosting library. In this case, the C library is initialized automatically as part of __main(), generated by the compiler when it sees main().
Applications which do not have a main() can still make stdio semihosting calls if an ANSI C semihosting library is (forcibly) linked in. However, in this case the C library is NOT initialized automatically (because the symbol __main was not generated), so the C library must be initialized manually instead."
Hi Tamir,
what you say does not contradict with my posting. The ARM C run-time environment is created in a multi-step procedure:
When you call main:
- You branch to __main which will copy non root execution regions from their load to execution region and decompress data sections.
- After __main is finished it will call __rt_entry which will first create the required heap environment (__rt_stack_heap()) and then initialize the library (__rt_lib_init()).
- After __rt_entry is done your provided main() is called and your programm execution begins.
As you can see, the ARM runtime environment is quiet flexible and allows you to provide your own methods for all these steps or avoid them at all.
Frank, I only tried to THANK you!
why on earth would anyone want to "develop a C program without any runtime libarry"
Erik
If you don't know of a reason and you've never considered the need, then it's probably something you don't need to concern yourself with.
I worked on a V55 project a few years ago and although I didn't totally exclude the runtime library, I had to make sure that absolute minimal use was made of it.
With sufficient understanding of the tools being used (in my case Microsoft), it is a reasonably straightforward task - And there is the key; you must have sufficient understanding of the tools being used.
Jeff, Your comments were very correct. I just had a look at the "libraries and floating point support guide" for RVCT 3.1: Man, giving up the runtime library is a messy business unless you really know what your doing!
View all questions in Keil forum