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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  Don Kinzer <dkinzer>
Submitted:  Fri 10 Feb 2012 04:17:12 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid Assigned to:  None
Percent Complete:  0% Open/Closed:  Closed
Release:  1.6.7 Fixed Release:  None

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>
Group 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.)

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
  • -email is unavailable- added by arcanum (Posted a comment)
  • -email is unavailable- added by gjlayde (Posted a comment)
  • -email is unavailable- added by dkinzer (Submitted the item)
  •  

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-11-16 arcanum StatusNeed Info Invalid
        Open/ClosedOpen Closed
    2012-11-16 arcanum StatusNone Need Info
    2012-02-10 dkinzer Attached File- Added t.c, #25040
        Attached File- Added makefile, #25041

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code