[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Re: [patch #6004] "main-as-normal" patches for GCC
From: |
Weddington, Eric |
Subject: |
RE: [avr-gcc-list] Re: [patch #6004] "main-as-normal" patches for GCC |
Date: |
Thu, 26 Feb 2009 09:47:08 -0700 |
> -----Original Message-----
> From:
> address@hidden
> [mailto:address@hidden
> org] On Behalf Of Bob Paddock
> Sent: Thursday, February 26, 2009 6:50 AM
> To: AVR-GCC
> Subject: Re: [avr-gcc-list] Re: [patch #6004]
> "main-as-normal" patches for GCC
>
> > The OS_main and OS_task attributes are mainly used for
> RTOSes, for the
> > main() function and task functions respectively. However,
> OS_main can be
> > useful in an application's main() function that does not
> have an RTOS,
> > as it will reduce the code size slightly.
>
> Is there any workable combination of OS_main and the noreturn
> attribute,
> that would prevent the compiler from inserting the _exit function?
>
> In the ideal case six bytes would be saved.
>
Interesting.
The whole exit stuff is spread across two projects.
The avr-libc startup (gcrt1.S) code contains the reference to exit:
.section .init9,"ax",@progbits
#ifdef __AVR_ASM_ONLY__
XJMP main
#else /* !__AVR_ASM_ONLY__ */
XCALL main
XJMP exit
#endif /* __AVR_ASM_ONLY__ */
; .endfunc
And exit is defined in libgcc here:
#ifdef L_exit
.section .fini9,"ax",@progbits
.global _exit
.func _exit
_exit:
.weak exit
exit:
/* Code from .fini8 ... .fini1 sections inserted by ld script. */
.section .fini0,"ax",@progbits
cli
__stop_program:
rjmp __stop_program
.endfunc
#endif /* defined (L_exit) */
So to be able to optimize this out, some changes would have to be done in gcc,
libgcc, and avr-libc....
But I think it's a good idea.
Eric Weddington