avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Uninitalized variables with gcc/g++


From: Peter Jansen
Subject: [avr-gcc-list] Uninitalized variables with gcc/g++
Date: Mon, 04 Feb 2002 14:20:09 +1100

Hi All,

I have been looking at how gcc/g++ stores uninitialized variables and it
appears to put them in the .data section, this then puts the some zeros
into the .data section to be copied into RAM by the startup code.

gcc puts these variables in the COM section, g++ puts them in the .data
section.

Attached it a patch to create these variables in the .bss section.

Regards,

-- 
Peter Jansen
Smart Container
Level 1, NIC Building
Eveleigh
NSW       1430
AUSTRALIA
*** gcc-3.0.2-patch-0.2/gcc/config/avr/avr.h    Wed Jan  9 14:11:19 2002
--- gcc-3.0.2-patch-0.3/gcc/config/avr/avr.h    Mon Feb  4 11:28:56 2002
***************
*** 1982,1998 ****
--- 1982,2002 ----
  
  
  #define TEXT_SECTION_ASM_OP "\t.text\t"
+ 
  /* A C expression whose value is a string containing the assembler
     operation that should precede instructions and read-only data.
     Normally `"\t.text"' is right.  */
  
  #define DATA_SECTION_ASM_OP "\t.data"
+ 
  /* A C expression whose value is a string containing the assembler
     operation to identify the following data as writable initialized
     data.  Normally `"\t.data"' is right.  */
  
  #define CONST_SECTION_ASM_OP  "\t.section\t.rodata"
  
+ #define BSS_SECTION_ASM_OP    "\t.section\t.bss"
+ 
  /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
  
     Note that we want to give these sections the SHF_WRITE attribute
***************
*** 2339,2344 ****
--- 2343,2363 ----
     These macros are provided by `real.h' for writing the definitions of
     `ASM_OUTPUT_DOUBLE' and the like:  */
  
+ #define ASM_OUTPUT_BSS(STREAM, DECL, NAME, SIZE, ROUNDED)                \
+     asm_output_bss(STREAM, DECL, NAME, SIZE, ROUNDED)
+ 
+ /* A C statement (sans semicolon) to output to the stdio stream
+    STREAM the assembler definition of a bss named NAME whose
+    size is SIZE bytes.  The variable ROUNDED is the size rounded up
+    to whatever alignment the caller wants.
+ 
+    Use the expression `assemble_name (STREAM, NAME)' to output the
+    name itself; before and after that, output the additional
+    assembler syntax for defining the name, and a newline.
+ 
+    This macro controls how the assembler definitions of uninitialized
+    global variables are output.  */
+ 
  #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)                        
   \
  do {                                                                     \
       fputs ("\t.comm ", (STREAM));                                       \

reply via email to

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