This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: x86 - linker optimization of "call *constant_variable" - feasible?
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 13 Aug 2003 14:53:56 +0930
- Subject: Re: x86 - linker optimization of "call *constant_variable" - feasible?
- References: <87n0eeji8s.fsf@codesourcery.com>
On Tue, Aug 12, 2003 at 09:26:11PM -0700, Zack Weinberg wrote:
> 0: e8 fc ff ff ff call 1 <foo+0x1>
> 1: R_386_PC32 B
> 5: ff 15 00 00 00 00 call *0x0
> 7: R_386_32 A
>
> The second call is significantly slower than the first, because of the
> extra memory fetch. I'm wondering whether it is feasible for the
> linker to optimize the second call into the first.
Yes, but you'd need to mark the call somehow (eg. with a new reloc type)
to indicate the call should be optimized. The reason being that
R_386_32 is used in other situations, and it's not safe for the linker
to read code bytes to determine whether R_386_32 applies to a call.
Consider
.text
my_fancy_ro_data_struct:
.long 0x15ff1234
.long foo
--
Alan Modra
IBM OzLabs - Linux Technology Centre