Common symbol size change bug

H. J. Lu hjl@lucon.org
Thu Apr 10 01:40:00 GMT 2003


On Wed, Apr 09, 2003 at 04:42:08PM -0700, H. J. Lu wrote:
> When a normal definition overrides a common symbol, ld complains:
> 
> # make
> gcc -O -g -c main.c
> gcc -O -g -c foo.c
> gcc -o foo1 -B./ main.o foo.o
> /usr/local/bin/ld: Warning: size of symbol `foo' changed from 8 to 16 in foo.o
> gcc -o foo2 -B./ foo.o main.o
> for f in foo1 foo2; do echo "Running: $f"; ./$f; \
>   if [ $? != 0 ]; then echo Failed; fi; done
> Running: foo1
> 0: 0
> 1: 1
> 2: 2
> 3: 3
> Running: foo2
> 0: 0
> 1: 1
> 2: 2
> 3: 3
> 
> But ld won't complain if a common symbol follows a normal definition.
> I don't think ld should complain. Here is a testcase. Am I missing
> something?
> 

Never mind. Sun linker does the same.


H.J.



More information about the Binutils mailing list