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

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

Re: [avr-libc-dev] noinitdata section ?


From: Theodore A. Roth
Subject: Re: [avr-libc-dev] noinitdata section ?
Date: Thu, 29 Aug 2002 23:25:15 -0700 (PDT)

On Wed, 28 Aug 2002, daniel_laptop wrote:

:)"Theodore A. Roth" wrote:
:)
:)> On Wed, 28 Aug 2002, daniel_laptop wrote:
:)>
:)> :) Has any of the noinitdata section been implemented ?
:)> :) If so - where can I find info. (source or doc file etc.) ?
:)> :) If not - is noinitdata going to be looked at ?
:)>
:)> Well, I just grep'ed for 'noinitdata' through all the files in binutils,
:)> gcc and avr-libc (all cvs, about a week old) and didn't see anything.
:)>
:)> Marek would know more about this than me.
:)>
:)
:)OK so "noinitdata" is all possible future stuff then ;-)

I was just digging around and saw this in one of the linker scripts 
(avr5.x):

  /* Global data not cleared after reset.  */
  .noinit  SIZEOF(.bss) + ADDR(.bss) :
  {
     PROVIDE (__noinit_start = .) ;
    *(.noinit*)
     PROVIDE (__noinit_end = .) ;
     _end = . ;
     PROVIDE (__heap_start = .) ;
  }  > data

Is this what you are looking for?

I just compiled a program with these global variable definitions:

  int foo __attribute__ ((section (".noinit")));
  int bar;
  int baz;

and the generated map file had this:

.bss            0x00800100        0x4
                0x00800100                PROVIDE (__bss_start, .)
 *(.bss)
 *(COMMON)
 COMMON         0x00800100        0x4 messy.o
                                  0x0 (size before relaxing)
                0x00800100                baz
                0x00800102                bar
                0x00800104                PROVIDE (__bss_end, .)
                0x00000116                __data_load_start = LOADADDR 
(.data)
                0x00000116                __data_load_end = 
(__data_load_start + SIZEOF (.data))

.noinit         0x00800104        0x2
                0x00800104                PROVIDE (__noinit_start, .)
 *(.noinit*)
 .noinit        0x00800104        0x2 messy.o
                0x00800104                foo
                0x00800106                PROVIDE (__noinit_end, .)
                0x00800106                _end = .
                0x00800106                PROVIDE (__heap_start, .)

and my list file shows this:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .data         00000000  00800100  00000116  000001aa  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  1 .text         00000116  00000000  00000000  00000094  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .bss          00000004  00800100  00800100  000001aa  2**0
                  ALLOC
  3 .noinit       00000002  00800104  00800104  000001aa  2**0
                  ALLOC
  4 .eeprom       00000000  00810000  00810000  000001aa  2**0
                  CONTENTS
  5 .stab         00000564  00000000  00000000  000001ac  2**2
                  CONTENTS, READONLY, DEBUGGING
  6 .stabstr      000004c3  00000000  00000000  00000710  2**0
                  CONTENTS, READONLY, DEBUGGING

finally, the code which clears the .bss section:

000000b2 <__do_clear_bss>:  
  b2:   11 e0           ldi r17, 0x01   ; 1
  b4:   a0 e0           ldi r26, 0x00   ; 0
  b6:   b1 e0           ldi r27, 0x01   ; 1
  b8:   01 c0           rjmp    .+2         ; 0xbc

000000ba <.do_clear_bss_loop>:
  ba:   1d 92           st  X+, r1

000000bc <.do_clear_bss_start>:
  bc:   a4 30           cpi r26, 0x04   ; 4
  be:   b1 07           cpc r27, r17
  c0:   e1 f7           brne    .-8         ; 0xba
  c2:   0c 94 65 00     jmp 0xca

I read this to addresses 0x100, 0x101, 0x102 and 0x103 are being set to zero 
("st  X+, r1") and then we jump into main. Since &foo -> 0x104, it doesn't 
get set to zero.

I'd like to know what this .noinit section is and what it's relationship to 
.bss is so that I can document it.

Is it possible to tell the linker where to put the .noinit section (i.e. at 
an address in a device that is memory mapped into the external sram space)?

Ted Roth





reply via email to

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