How can I change the compile  characteristic of  .bss section  in CW6.3 ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I change the compile  characteristic of  .bss section  in CW6.3 ?

1,858 Views
Tang
Contributor I
Hello.
In CW6.3 ,the first defined bss varible will always  be compiled  to the last address of  bss section.

For example,the bss section is located in 0x2000_0000~0x2000_ffff, and i define two bss variables in *.h file
:unsigned int var1;
 unsigned int var2;

In the MAP file,the address of var1 will be 0x2000_0004, var2 will be 0x2000_0000.

In my project ,I want the address of var1 is 0x2000_0000, var2  is 0x2000_0004.

How can I get it?
Thanks.
Labels (1)
0 Kudos
3 Replies

472 Views
Tang
Contributor I
Thanks.
You are so helpful!
0 Kudos

472 Views
CrasyCat
Specialist III
Hello
 
Please note that there is no requirement in the ANSI C standard that the variables symbols) will be allocated in the sequence they have been defined.
 
A compiler/linker may change the order of allocation.
 
If you really need the object/symbols to be allocated in a certain sequence, I would recommend you to define a structure and access the fields in there through a macro.
 
Example:
struct {
:unsigned int var1;
 unsigned int var2;
}MyStruct;
 
#define var1 MyStruct.var1
#define var2 MyStruct.var2
 
CrasyCat
0 Kudos

472 Views
J2MEJediMaster
Specialist I
Check the following lengthy thread for information on how to locate sections.

---Tom

0 Kudos