This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: program crashes on startup when compiled with 'recent' gcc


ZdenÄk Sojka <zsojka@seznam.cz> writes:

> This is the content of file.s
> 	.file	"file.cpp"
> 	.weak	_ZGVZN1A4InitEvE1i
> 	.section	.bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZZN1A4InitEvE1i,comdat
> 	.align 8
> 	.type	_ZGVZN1A4InitEvE1i, @object
> 	.size	_ZGVZN1A4InitEvE1i, 8
> _ZGVZN1A4InitEvE1i:
> 	.zero	8
> 	.ident	"GCC: (GNU) 4.5.0 20091006 (experimental)"
> 	.section	.note.GNU-stack,"",@progbits
>
> when compiled with older gcc, the only (apart from .ident) line changed is
> 	.section	.bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZGVZN1A4InitEvE1i,comdat
> so I thought _ZGVZN1A4InitEvE1i is correct there.

I see.  The guard variable is being emitted in a group attached to a
symbol which is not defined.  I don't know why the guard variable is
being emitted at all here.  It's definitely wrong to emit the guard
variable without emitting the variable which it guards.  That is the
bug.

What changed recently is that the guard variable was moved into the
correct section group.  In general that should be a good change.
Unfortunately, when only the guard variable is emitted, it has the
side effect of causing the linker to discard the real variable
definition.  Since the variable is weak, the program links OK, and
crashes at runtime.

Could you please open a bug report about this, according to
http://gcc.gnu.org/bugs.html ?  It suffices to show that your file.cpp
defines a guard variable without defining the variable which it
guards.  Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]