Bug 19008 - symbol references from notes sections result in errors with -gc-sections
Summary: symbol references from notes sections result in errors with -gc-sections
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-25 17:05 UTC by Andi Kleen
Modified: 2015-09-29 13:37 UTC (History)
2 users (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 Andi Kleen 2015-09-25 17:05:42 UTC
Since some time I get boot strap errors with gcc on systems with systemtap installed. It fails when linking libsupc++ like this (PR60946).

systemtap sets up some complicated data structures in notes to describe trace points.

`_.stapsdt.base' referenced in section `.note.stapsdt' of ../libsupc++/.libs/libsupc++convenience.a(eh_catch.o): defined in discarded section `.stapsdt.base[.stapsdt.base]' of ../libsupc++/.libs/libsupc++convenience.a(eh_catch.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of ../libsupc++/.libs/libsupc++convenience.a(eh_throw.o): defined in discarded section `.stapsdt.base[.stapsdt.base]' of ../libsupc++/.libs/libsupc++convenience.a(eh_catch.o)
`_.stapsdt.base' referenced in section `.note.stapsdt' of ../libsupc++/.libs/libsupc++convenience.a(eh_throw.o): defined in discarded section `.stapsdt.base[.stapsdt.base]' of ../libsupc++/.libs/libsupc++convenience.a(eh_catch.o)
collect2: error: ld returned 1 exit status

I can work around it by commenting use use of -gc-sections for libstdc++.

This seems like a bug. Even with gc-sections symbol references from notes sections should not result in an error.

GNU ld version 2.25-8.fc22
Comment 1 H.J. Lu 2015-09-25 18:00:25 UTC
Please provide procedure how to reproduce it.
Comment 2 Andi Kleen 2015-09-25 18:03:54 UTC
Install systemtap-devel on Fedora
Do a gcc bootstrap
Comment 3 H.J. Lu 2015-09-25 21:21:17 UTC
Please try binutils master branch.
Comment 4 H.J. Lu 2015-09-25 21:32:43 UTC
Are you using ld or gold?  I have no problems with ld.
Comment 5 Andi Kleen 2015-09-25 22:56:45 UTC
I'm using ld

ld --version
GNU ld version 2.25-8.fc22
Comment 6 H.J. Lu 2015-09-26 01:43:51 UTC
(In reply to Andi Kleen from comment #5)
> I'm using ld
> 
> ld --version
> GNU ld version 2.25-8.fc22

Please try binutils master branch.
Comment 7 Andi Kleen 2015-09-26 17:20:22 UTC
binutils mainline can't build gcc

/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (3168)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (2884)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (1858)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (2688)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (2379)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (3136)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (3310)
/usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section (1947)
/usr/local/bin/ld-plugin: _muldi3_s.o(.debug_info+0x53c): reloc against `.debug_str': error 2


Lots of these messages
Comment 8 Alan Modra 2015-09-27 00:03:02 UTC
I don't see anything like that here, on x86_64-linux with
GNU ld (GNU Binutils) 2.25.51.20150926
xgcc (GCC) 6.0.0 20150926 (experimental)

Perhaps your binutils is miscompiled?  I suggest starting off the bootstrap process from a known good system compiler.
Comment 9 Andi Kleen 2015-09-27 14:54:56 UTC
Binutils was compiled with the system compiler


Did a separate build on binutils

Then bootstrapped gcc with PATH=/path/to/binutils/bin:$PATH ....
Comment 10 H.J. Lu 2015-09-28 14:53:41 UTC
(In reply to Andi Kleen from comment #7)
> binutils mainline can't build gcc
> 
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (3168)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (2884)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (1858)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (2688)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (2379)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (3136)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (3310)
> /usr/local/bin/ld-plugin: _muldi3_s.o: access beyond end of merged section
> (1947)
> /usr/local/bin/ld-plugin: _muldi3_s.o(.debug_info+0x53c): reloc against
> `.debug_str': error 2
> 
> 
> Lots of these messages

Please send me all input files to reproduce this linker error.
Comment 11 H.J. Lu 2015-09-29 13:37:38 UTC
It is a pilot error.