[En-Nut-Discussion] GCC and main
Harald Kipp
harald.kipp at egnite.de
Tue Jan 26 19:06:38 CET 2010
Hi all,
in early days, avr-libc handles main like any other function.
Unfortunately, some years ago, the maintainers of the AVR toolchain
decided to handle it special, in order to save a few bytes for the tiny
AVRs.
Then, in 2006, a patch appeared, which restores the original behavior
http://sourceware.org/ml/binutils/2006-05/msg00239.html
Unfortunately the "officials" refused this and we want back to special main.
The problem for Nut/OS is, that modifying the stack pointer on main
entry will crash the system. On the other hand I always refused to move from
int main(void)
{
return 0;
}
to something like
int NutMain(void)
{
return 0;
}
and place main into Nut/OS code. Simply because I expect a C application
to start with main(). Everything else looks strange to me.
Right now we use
#define main NutMain
This makes our applications look "normal", but it sometimes confuses the
debugger or people who try to located main in the linker map file.
Well, while trying to get this old eboot bootloader compiled with the
latest avr-gcc, I recognized, that we are back to the ordinary main
entry (without setting the stack pointer). The bootloader, while
fighting for every extra byte, relied on the special main handling and
failed with newer toolchains.
I further assume, that arm-elf-gcc always handled main as an ordinary
function, but I'm not sure.
Shall we finally remove the #define of main? What do you think?
Harald
More information about the En-Nut-Discussion
mailing list