Bug 10219 - Can't get stab symbols when linking with gold
Summary: Can't get stab symbols when linking with gold
Status: VERIFIED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-29 23:19 UTC by Lei Zhang
Modified: 2009-06-26 18:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lei Zhang 2009-05-29 23:19:03 UTC
Using gold build from [1] and a 32-bit dump_syms from Google breakpad. Take a
hello world program and compile it without gold:

gcc -m32 -gstabs hello.c -o hello

and then run dump_syms hello will produce:
 
MODULE Linux x86 1888DA9DFDD4858254E7EA9FD030F83D0 hello
FILE 0 hello.c
FUNC 374 2b 0 main
374 11 4 0
385 c 5 0
391 5 6 0
396 9 7 0

then run:
gcc -m32 -gstabs -B/path/to/dir_with_gold hello.c -o hello

and I get:

MODULE Linux x86 C170460C4897C338F08D0B7886DAD6D50 hello
FUNC 1e4 2b 0
1e4 11 4 -1
1f5 c 5 -1
201 5 6 -1
206 9 7 -1


[1] ftp://sourceware.org/pub/binutils/snapshots/binutils-2.19.51.tar.bz2
Comment 1 Sourceware Commits 2009-06-24 00:38:15 UTC
Subject: Bug 10219

CVSROOT:	/cvs/src
Module name:	src
Changes by:	ian@sourceware.org	2009-06-24 00:38:00

Modified files:
	gold           : ChangeLog layout.cc layout.h 

Log message:
	PR 10219
	* layout.cc (Layout::Layout): Initialize have_stabstr_section_.
	(Layout::make_output_section): Set have_stabstr_section_ if we see
	a .stab*str section.
	(Layout::finalize): Call link_stabs_sections.
	(Layout::link_stabs_sections): New file.
	* layout.h (class Layout): Add have_stabstr_section_ field.
	Declare link_stabs_sections.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.248&r2=1.249
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.cc.diff?cvsroot=src&r1=1.128&r2=1.129
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/layout.h.diff?cvsroot=src&r1=1.65&r2=1.66

Comment 2 Ian Lance Taylor 2009-06-24 00:39:31 UTC
Thanks for the bug report.  The GNU linker links .stab and .stabstr sections,
and dump_syms was relying on that to find the .stabstr section.  I just
committed a patch to gold to link the sections in the same way, which fixes this
problem.
Comment 3 Lei Zhang 2009-06-26 18:17:58 UTC
Works for me.