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

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

Re: [avr-libc-dev] [RFC] sections stub patch


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] [RFC] sections stub patch
Date: Wed, 28 Aug 2002 12:49:04 +0200
User-agent: Mutt/1.2.5i

As Theodore A. Roth wrote:

> How's this for a start on documenting sections?

Some comments, also only from reading the source. ;)

> +  <tr>
> +     <td><tt>.init4</tt></td>
> +     <td>Copies data from flash to SRAM. [Is this BSS init?]</td>
> +  </tr>

It is both, initializing .data and initializing .bss.  In Unix-like
targets, .data is normally initialized by the OS directly from the
executable file.  Since this is impossible in an MCU environment,
avr-gcc instead takes care of appending the .data variables after
.text in the flash ROM image.  .init4 then defines the function
weakly() which takes care of copying the contents of .data from the
flash to SRAM.

Initializing .bss just means to zero it out, but that's indeed also
done inside .init4.

Btw., if you look into the ld script(s), you'll notice that there's
also .init6 and .fini6 used for C++ constructors/destructors, .fini9
is used to implement _exit() (normally obviously just empty), and
.fini0 is used for the infinite loop.  All of this seems to be
implicit knowledge of avr-gcc.

> +\subsection c_sections Using Sections in C Code
> +
> +Example:
> +
> +\code
> +#include <avr/io.h>
> +
> +void my_init_portb (void) __attribute__ ((naked)) \
> +    __attribute__ ((section (".init1")));
> +
> +void
> +my_init_portb (void)
> +{
> +     outb (PORTB, 0xff);
> +     outb (DDRB,  0xff);
> +}
> +\endcode
> +
> +*/

Hmm, if you put that here, the FAQ could be updated to just xref this
part instead of using the examples directly there.  By now, i simply
merged Marek's and your mail to the list in order to produce the
appropriate FAQ entry.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/




reply via email to

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