This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB 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]

symtab/1330: dwarf2read doesn't apply .rela.debug_xxx relocations


>Number:         1330
>Category:       symtab
>Synopsis:       dwarf2read doesn't apply .rela.debug_xxx relocations
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 10 17:58:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     kisch@sesamstrasse.dyndns.tv
>Release:        5.3
>Organization:
>Environment:
powerpc-yellowdog-linux-gnu, Linux Kernel 2.4.21rc8
binutils 2.14.90.0.4
gcc 3.2.2
>Description:
gdb doesn't correctly load dwarf2 debug info from object files containing multiple compilation units.

This seems to be caused by not applying any relocation info sections present in the object for the debug info sections.

The error does not seem to happen in an i386 environment, presumably because a different relocation scheme is used.

Compare binutils-2.14.90.0.4/binutils/readelf.c:8372.
readelf --debug-dump=info gives correct debug info for my testcase object file. But if I disable the relocation algorithm in readelf.c, I get corrupted output from readelf which is completely consistent with that from gdb. (BTW, readelf from binutils 2.13.90.0 fails, too)

On the other hand, when the relocation info for the debug sections is applied manually on the object file before loading it into gdb, all is well. 

>How-To-Repeat:
cat <<EOF >a.c
typedef unsigned long ulong;
ulong a (ulong u) { return u+1; }
EOF

cat <<EOF >b.c
typedef unsigned short ushort;
ushort b (ushort u) { return u+1; }
EOF

gcc -c -g -fPIC a.c
gcc -c -g -fPIC b.c
ld -r -o c.o a.o b.o

gdb c.o
info functions

actual output:
ushort a (ushort u)
tmp b (tmp u)

(the string "tmp" is part (!) of the DW_AT_comp_dir string present in the debug info. The actual output would also probably depend on length of the DW_AT_producer string.)

expected output:
ushort a (ushort u)
ulong b (ulong u)
>Fix:
It seems that any relocation info from the sections .rela.debug_info, .rela.debug_abbrev (checked only these two for now) and probably also from the other .rela.debug_xxx sections has to be applied to the .debug_xxx sections before evaluating them (dwarf2_read_section() seems a good place).
>Release-Note:
>Audit-Trail:
>Unformatted:


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