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