Bug 6019 - [avr] avr-ld --relax requires --gc-sections
Summary: [avr] avr-ld --relax requires --gc-sections
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-31 22:26 UTC by Eric Weddington
Modified: 2014-05-28 19:41 UTC (History)
1 user (show)

See Also:
Host:
Target: avr-*-*
Build:
Last reconfirmed:


Attachments
Test case. (39.44 KB, application/binary)
2008-05-25 20:14 UTC, Eric Weddington
Details
reduced test case (746 bytes, text/plain)
2008-05-29 21:39 UTC, Jevin Sweval
Details
Add test for no local symbols (369 bytes, patch)
2008-05-30 15:37 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Weddington 2008-03-31 22:26:34 UTC
avr-ld fails with --relax, unless --gc-sections is also used, even if
-ffunction-sections is not used with avr-gcc.
Comment 1 Nick Clifton 2008-05-21 11:23:10 UTC
Hi Eric,

  Please can you provide a test case for this ?

Cheers
  Nick
Comment 2 Eric Weddington 2008-05-25 20:14:03 UTC
Created attachment 2756 [details]
Test case.

This zip file contains the source code of a project that exhibits the bug, and
it contains a short build script. This source code comes from WinAVR
(SourceForge) bug #1819125:
<http://sourceforge.net/tracker/index.php?func=detail&aid=1819125&group_id=68108&atid=520074>
Comment 3 Eric Weddington 2008-05-25 20:15:09 UTC
Unfortunately this is all I have in the way of test case. I know that it is too
large, but I haven't had time to investigate into a smaller test case.
Comment 4 Eric Weddington 2008-05-25 20:17:12 UTC
Note that in the build script, using -Wl,--relax causes ld to fail. Using
-Wl,--relax,--gc-sections causes the link to be successful. This is with a
host=mingw toolchain. I have not verified the bug on a host=linux toolchain.
Comment 5 Jevin Sweval 2008-05-29 21:39:59 UTC
Created attachment 2766 [details]
reduced test case

test with:
avr-gcc -c -o onewire.o -Os onewire.i
avr-gcc -Wl,--relax -o onewire.elf onewire.o

-Os is necessary and the linker doesn't crash with --gc-sections
Comment 6 Jevin Sweval 2008-05-29 21:42:47 UTC
I've attached a reduced test case made with multidelta. It got minimized to 11
meaningful lines. It was run through the preprocessor before minimization so the
actual code is hard to read but I doubt that really matters.
Comment 7 Nick Clifton 2008-05-30 15:37:17 UTC
Created attachment 2768 [details]
Add test for no local symbols
Comment 8 Nick Clifton 2008-05-30 15:38:42 UTC
Hi Eric, Hi Jevin,

  Please could you try out the uploaded patch and let me know if it works for
you ?  (I am especially interested to know if it works on the real programs
where you encountered this bug, not just the reduced testcase).

Cheers
  Nick
Comment 9 Eric Weddington 2008-06-02 16:37:20 UTC
Patch fixes bug on real-world application. 

Thanks, Nick!
Comment 10 Nick Clifton 2008-06-04 09:59:03 UTC
Hi Guys,

  Great - I have applied the patch along with the changelog entry below.

Cheers
  Nick

bfd/ChangeLog
	PR ld/6019
	* elf32-avr.c (elf32_avr_relax_section): Handle the case where
	there are no local symbols.
Comment 11 Jackie Rosen 2014-02-16 16:57:11 UTC
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.