avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Request: gcrt1.S with empty section .init9


From: Marko Mäkelä
Subject: [avr-libc-dev] Request: gcrt1.S with empty section .init9
Date: Fri, 6 Jan 2017 17:21:03 +0200
User-agent: NeoMutt/20161126 (1.7.1)

I am trying to move from assembler to C programming on the AVR while avoiding unnecessary overhead. I see that crt1/gcrt1.S contains the following code:

        .section .init9,"ax",@progbits
#ifdef __AVR_ASM_ONLY__
        XJMP    main
#else   /* !__AVR_ASM_ONLY__ */
        XCALL   main
        XJMP    exit
#endif  /* __AVR_ASM_ONLY__ */

The above references to main() and exit() are needed for complying with the C standard. However, I would tend to believe that normally programs written for bare metal (such as the AVR) never terminate. Such programs do not need an exit() function or even a call or jump to main().

Would it be possible to introduce a (necessarily non-standard) option that allows the .init9 section of the runtime libary to be omitted? Then, the user could declare their infinite main loop something like this:

__attribute__((naked)) __attribute__((section(".init9")))
static
void
mainloop (void)
{
        for (;;) do_my_stuff ();
}

This would save 3 instructions and some RAM (call main/ret, jump exit).

I am aware of the linker options -nostartfiles -nostdlib, but I do want the interrupt table and the sections .init0 through .init8.

Perhaps .linkonce or some clever use of .weak could help here? Or perhaps an alternative crt.o file could be provided for a minimal startup?

I would have tried to patch gcrt1.S myself, but I am having trouble setting up the build environment.

Best regards,

        Marko



reply via email to

[Prev in Thread] Current Thread [Next in Thread]