This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/46072] AIX linker chokes on debug info for uninitialized static variables
- From: "michael.haubenwallner at salomon dot at" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 25 Jan 2011 12:52:46 +0000
- Subject: [Bug target/46072] AIX linker chokes on debug info for uninitialized static variables
- Auto-submitted: auto-generated
- References: <bug-46072-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46072
--- Comment #4 from Michael Haubenwallner <michael.haubenwallner at salomon dot at> 2011-01-25 12:52:22 UTC ---
What exactly is the difference for gcc between not initializing a static
variable and initializing it to zero?
This is the difference in the generated assembler file:
$ cat mytest.c
static int myvar;
int main(void)
{
return myvar;
}
#if defined(IVAL)
static int myvar = IVAL;
#endif
For the compilation:
$ gcc -g mytest.c -DIVAL=0
(success)
$ gcc -g mytest.c
ld: 0711-593 SEVERE ERROR: Symbol C_BSTAT (entry 29) in object
/tmp//cc26KLXk.o:
The symbol refers to a csect with symbol number 0, which was not
found. The new symbol cannot be associated with a csect and
is being ignored.
collect2: ld returned 12 exit status
(fail)
For the analysis:
$ gcc -g -S mytest.c -o mytestu.s
$ gcc -g -S mytest.c -o mytest0.s -DIVAL=0
$ diff -u mytestu.s mytest0.s
--- mytestu.s 2011-01-25 13:39:43.000000000 +0100
+++ mytest0.s 2011-01-25 13:40:01.000000000 +0100
@@ -42,7 +42,7 @@
.byte 31
.align 2
FE..main:
- .bs _mytest.bss_
+ .bs _mytest.rw_[RW]
.stabx "myvar:S-1",myvar,133,0
.es
_section_.text:
Both gcc-4.5.1 and gcc-4.2.4 do make this difference.