bug-gnu-utils
[Top][All Lists]
Advanced

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

ld emits nonsense debug-info for global variables


From: Peter . Gsellmann
Subject: ld emits nonsense debug-info for global variables
Date: Mon, 4 Mar 2002 20:28:45 +0100

Under some circumstances the linker produces nonsense debug-info for global
variables.
It depends on the order of the include files being different in the two .c-files

This is the shortest and simplest example i can produce the error with.
Run the appended shellscript which generates the sourcefiles and produces the 
following output:

167    GSYM   0      3      00000000 5027   variable2:G(2,5)
192    GSYM   0      2      00000000 5051   variable1:G(1,5)

variable1 is assigned to the nonexistent type (1,5) !
but variable1 should be identical to variable2 (which has the correct debug 
info).

The debug-info is correct in the object files generated by the compiler.
The type (1,5) can be found in the file data.o .
I suspect the linker does not 'relocate' the type (1,5) to (2,5) when it merges
the identical infos for struct sc from the two object-files.

I have configured the binutils and compiler for an embedded target i386-elf and 
i
_need_ the correct debug-info for post-processing the output-file.

Peter

versions ------------------------
ld --version 2.11.92 20011001
ld --version 2.9.5
gcc --version 2.95.3-5
gcc --version 2.95.2
host is cygwin and/or linux

--------------------------
#!/bin/sh
echo "typedef struct { unsigned u; } sb;"     > data.h
echo "typedef struct { struct sb *p; } sc;"  >> data.h
echo "#define EMPTYFILE"         > empty.h
echo "#include \"empty.h\""      > prog.c
echo "#include \"data.h\""      >> prog.c
echo "struct sb * variable2;"   >> prog.c
echo "int main(){return 0;}"    >> prog.c
echo "#include \"data.h\""       > data.c
echo "struct sb * variable1;"   >> data.c
gcc -g -Wall prog.c data.c -o atask.out
objdump --stabs atask.out | grep variable
gcc -g -Wall prog.c -c -o prog.o
gcc -g -Wall data.c -c -o data.o
--------------------------





reply via email to

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