This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86 - linker optimization of "call *constant_variable" - feasible?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]