Wow.  Total brain reversal.  When I said:
 
    Here we only care about its job as a scope modifier.
 
I really meant
 
    Here we only care about its job as a storage class specification.
 
Sorry about that.
 
I'm relatively new to msp430 and mspgcc so if I have misspoken in other
places please let me know.

________________________________

From: mspgcc-users-ad...@lists.sourceforge.net
[mailto:mspgcc-users-ad...@lists.sourceforge.net] On Behalf Of
Christopher E Piggott
Sent: Wednesday, February 01, 2006 12:05 PM
To: mspgcc-users@lists.sourceforge.net
Subject: RE: [Mspgcc-users] [.bss and other questions]


The .bss section contains data that meets the following rules:
    1) it is uninitialized
    2) its storage class is static
 
In C, this pertains to:
    * things that are defined outside of a function AND are not
initialized to a non-zero value
    * things that are defined within a function but declared 'static'
AND are not initialized to a non-zero value
 
In this example, x, y, and z will all go into bss:
 
    int x;
    static int y;
    function xyz() {
        static int z;
        ...
    }
 
note that declaring int y as 'static' affects the scope, not the storage
class.  This can be confusing until you realize that 'static' means two
things in C: it is a scope modifier, and it is a storage class
specifier.  Here we only care about its job as a scope modifier.
 
If you assign an initial, non-zero value then something happens.  Here
is another example:
 
int c = 10;
function hello() {
    static int p = 69;
    ...
}
 
In this second example, neither c nor p go into bss.
 
Now, realize one more thing: by "uninitialized" most C compilers really
mean "initialize it to zero."  In mspgcc this happens in the prolog code
that is generated before main (provided you don't give the compiler a
flag that tells it not to generate this code).  Take your main module
and run msp430-objdump -d on it and look at it; you can see a loop that
clears .bss.
 
Suppose you have a large amount of static data, and you do not want to
waste time initializing it to zero because you don't care.  That's fine,
too; these things you would specify go into .noinit instead.  Start-up
time is probably the main reason you would do this.  Some compilers will
by default zero-initialize "small" data (simple types) but leave
"non-small" data (complex data types like structures) uninitialized.
 
 
So the next logical question is: how does my initialized static data get
set to the proper value on startup?
 
If you declare the data as constant, then it doesn't have to be.  The
compiler will be smart enough to just leave the value in ROM somewhere,
or in some cases optimize the variable out entirely and insert it inline
every time you refer to that constant.  If it isn't constant, then it
needs to be put into .data and the initial values copied from rom.
Again, this happens in the prolog to main, so it's worth taking a look
at it if only for the education experience.  The prolog code knows where
to copy the initial values from because the linker configuration file
tells it when it says:
 
    PROVIDE (__data_start_rom = _etext) ; 
    PROVIDE (__data_end_rom   = _etext + SIZEOF (.data)) ;
 
What that is telling you is that the initial values are in the flash
after the end of the code.
 
I think this addreses your main question.  As for your error:
 
 
msp430-ld: section .bss [00001f92 -> 00007e3b] overlaps section .text
[00002500-> 0000bf65] 

You're simply overflowing .bss ... you either have too much stuff in it,
or you have placed it in the wrong spot.
 
--Chris
 

________________________________

From: mspgcc-users-ad...@lists.sourceforge.net
[mailto:mspgcc-users-ad...@lists.sourceforge.net] On Behalf Of axs
Sent: Wednesday, February 01, 2006 11:15 AM
To: mspgcc-users@lists.sourceforge.net
Subject: [Mspgcc-users] [.bss and other questions]




---------- Forwarded message ----------
List,


* Can somebody explain to me what is the .bss section, and the .noinit
section?
("man elf" doesn't help me, in fact the man doesn't mention the .noinit
section) 


* The .data section, is some kind of image of the variables involved in
the program? 
In that case, at startup it'll be loaded in ram, in that case, how? 


* About the output below, as you can see I'm trying to link a program,
but the link errors really confuse me, in fact i don't understand the
messages. 
Because, if i have 48 KB available in ROM and 10 KB in RAM, how and why
the .bss is not within region data, the same for the .noinit.
In the list archives, I saw questions about this, but no one helped me.




        ADMRED-25459# make 
        msp430-gcc -O3 -O -c -DSTAND_ALONE_INTERP -mmcu=msp430x1612
driver.c
        msp430-gcc -O3 -O -c -DSTAND_ALONE_INTERP -mmcu=msp430x1612
canon_stand_alone.c
        msp430-gcc -O3 -O -c -DSTAND_ALONE_INTERP -mmcu=msp430x1612
file.c
        msp430-gcc -O3 -O -c -DSTAND_ALONE_INTERP -mmcu=msp430x1612
rs274ngc.c
        msp430-gcc -O3 -O -c -DSTAND_ALONE_INTERP -mmcu=msp430x1612
math.c
        msp430-gcc -lm -m msp430x1612 -O3 -O driver.o
canon_stand_alone.o rs274ngc.o file.o math.o -o rs274ngc.interpreter
        msp430-ld: address 0x7e3c of rs274ngc.interpreter section .bss
is not within region data 
        msp430-ld: address 0x7e3c of rs274ngc.interpreter section
.noinit is not within region data 
        msp430-ld: section .bss [00001f92 -> 00007e3b] overlaps section
.text [00002500-> 0000bf65] 
        C:\axs\unixutils\gnu-tools\usr\local\wbin\make.EXE: ***
[rs274ngc.interpreter] Error 1 
        ADMRED-25459# msp430-size *.o
           text    data     bss     dec     hex filename
            626       6      12     644     284 canon_stand_alone.o 
           4366       0       0    4366    110e driver.o
             54       6       0      60      3c file.o
             90       0       0      90      5a math.o
          28990    3716      50   32756    7ff4 rs274ngc.o 
        ADMRED-25459#
        


As you can see, the questions are more for a gcc list, sorry for bother.

 

Reply via email to