bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/13683] New: usage tracking by --gc-sections ignores a --defsym m


From: dkinzer at zbasic dot net
Subject: [Bug ld/13683] New: usage tracking by --gc-sections ignores a --defsym mapping
Date: Sat, 11 Feb 2012 21:18:06 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=13683

             Bug #: 13683
           Summary: usage tracking by --gc-sections ignores a --defsym
                    mapping
           Product: binutils
           Version: 2.19
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: address@hidden
        ReportedBy: address@hidden
    Classification: Unclassified


Created attachment 6208
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6208
test case makefile and C source

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 when compiled
for an AVR target. 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 incorrect code
with no 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 three candidate functions
indicating the the linker code that eliminates unused functions determined that
they were all unused even though "foo2" should have been marked as used.

I attempted to confirm this issue for an x86 target (ld v2.21.1) but it
appeared that --gc-sections didn't remove any unused functions.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]