bugAVR C Runtime Library - Bugs: bug #35500, --gc-sections doesn't track use...

 
 

bug #35500: --gc-sections doesn't track use via --defsym

Submitted by:  Don Kinzer <dkinzer>
Submitted on:  Fri 10 Feb 2012 04:17:12 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: InvalidPercent Complete: 0%
Assigned to: NoneOpen/Closed: Closed
Release: 1.6.7Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 16 Nov 2012 08:32:19 PM UTC, comment #3:

Whatever it is, it's not an AVR Libc problem as I already said.

Georg-Johann Lay <gjlayde>
Fri 16 Nov 2012 06:47:10 PM UTC, comment #2:

Don, Johann,

Is this still an issue?

Eric Weddington <arcanum>
Project Administrator
Sat 11 Feb 2012 11:24:30 AM UTC, comment #1:

> I'm not sure that this is the right place to report
> this problem


It's not the right place. F'up to binutils [1] and [2].

> In this simple test case, main calls a non-existent
> function "foo" and the linker option --defsym,foo=foo2
> is used to map the call to the desired function.
> If the link step is performed without the --gc-sections
> option, the resulting executable is correct [...]
> However, adding --gc-sections to the link options produces
> this code [...]
> The resulting load image contains none of the candidate
> functions indicating the the linker code that eliminates
> unused functions believed that they were all unused even
> though "foo2" should have been marked as used.


With such hack you are at the bleeding edge. You can try if the function attribute "used" works for you, see [3].

[1] http://sourceware.org/binutils/
[2] http://sourceware.org/bugzilla/
[3] http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Function-Attributes.html

Georg-Johann Lay <gjlayde>
Fri 10 Feb 2012 04:17:12 PM UTC, original submission:

I'm not sure that this is the right place to report this problem but I'll do so as a first step.

I have a use case where I need to perform link-time mapping of a function call to one of several differently named candidates having the same parameter lists and return type. In the actual use case all of the candidate functions are in a library but that fact is not relevant to the problem that arises.

The attached .c and makefile can be used to observe the problem. In this simple test case, main calls a non-existent function "foo" and the linker option --defsym,foo=foo2 is used to map the call to the desired function. If the link step is performed without the --gc-sections option, the resulting executable is correct as shown in this .lss excerpt:

000000e0 <main>:
e0: f7 df rcall .-18 ; 0xd0 <foo2>
e2: ff cf rjmp .-2 ; 0xe2 <main+0x2>

However, adding --gc-sections to the link options produces this code with warning or error messages:
000000c8 <main>:
c8: 9b df rcall .-202 ; 0x0 <__vectors>
ca: ff cf rjmp .-2 ; 0xca <main+0x2>

The resulting load image contains none of the candidate functions indicating the the linker code that eliminates unused functions believed that they were all unused even though "foo2" should have been marked as used.

This issue was observed with v4.3.3. I haven't tested this with a later version of the toolchain.

Don Kinzer <dkinzer>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #25040:  t.c added by dkinzer (210B - text/x-csrc)
file #25041:  makefile added by dkinzer (839B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by arcanum (Posted a comment)
  • -unavailable- added by gjlayde (Posted a comment)
  • -unavailable- added by dkinzer (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 16 Nov 2012 09:12:06 PM UTCarcanumStatusNeed Info=>Invalid
      Open/ClosedOpen=>Closed
    Fri 16 Nov 2012 06:47:10 PM UTCarcanumStatusNone=>Need Info
    Fri 10 Feb 2012 04:17:12 PM UTCdkinzerAttached File-=>Added t.c, #25040
      Attached File-=>Added makefile, #25041

    Back to the top


    Powered by Savane 3.1-cleanup