This is the mail archive of the
mailing list for the binutils project.
Re: ARM: calls to undefined weak symbols
- From: Phil Blundell <pb at pbcl dot net>
- To: Christian Groessler <chris at groessler dot org>, binutils at sourceware dot org
- Date: Wed, 02 Mar 2016 13:23:11 +0000
- Subject: Re: ARM: calls to undefined weak symbols
- Authentication-results: sourceware.org; auth=none
- References: <56D6E5AC dot 8080106 at groessler dot org>
On Wed, 2016-03-02 at 14:07 +0100, Christian Groessler wrote:
> it just occurred to me: couldn't calls to undefined weak symbolsÂ
> completely be removed
> instead of being replaced by a 'nop' (when doing a 'relaxing' link)?
In general no, they can't, because the linker doesn't have enough
information available to fix up the other places that would need
adjusting afterwards. ÂFor example, if you had:
Â Â Â Â Â.text
cmp Âr0, #1
addÂÂÂÂÂr0, r0, #1
then the "bne 2f" will be completely resolved by the assembler and if
the linker starts adding or removing instructions then the branch
target will point to the wrong location.
Of course, this particular example would be eminently fixable by having
the assembler output a suitable reloc and symbol definition and letting
the linker do the resolution instead. ÂHow easy it would be to identify
and fix up all the other possible places that offsets between
instructions (or between instructions and data) might get encoded into
object files before the linker sees them is less obvious. Â
Clearly it wouldn't be impossible to make this work but, given that
branches to unresolved weaks are fairly uncommon and the cost of a
single nop on a modern cpu is more or less negligible, it seems like it
would be quite a lot of effort for not much benefit.