This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: MIPS PLT entry
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: "Fu, Chao-Ying" <fu at mips dot com>
- Cc: Richard Sandiford <rdsandiford at googlemail dot com>, binutils at sourceware dot org
- Date: Thu, 16 Jul 2009 21:19:57 +0100 (BST)
- Subject: RE: MIPS PLT entry
- References: <94BD67F8AF3ED34FA362C662BA1F12C502BB5CE5@MTVEXCHANGE.mips.com>
On Wed, 15 Jul 2009, Fu, Chao-Ying wrote:
> @@ -9352,11 +9362,26 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd
> load = MIPS_ELF_LOAD_WORD (output_bfd);
>
> /* Fill in the PLT entry itself. */
> - plt_entry = mips_exec_plt_entry;
> + if ((elf_elfheader (output_bfd)->e_flags & EF_MIPS_ARCH)
> + == E_MIPS_ARCH_1)
> + plt_entry = mips_exec_plt_entry;
> + else
> + /* We can use the fast PLT entry for non-MIPS1 CPUs. */
> + plt_entry = mips_exec_fast_plt_entry;
> bfd_put_32 (output_bfd, plt_entry[0] | got_address_high, loc);
> bfd_put_32 (output_bfd, plt_entry[1] | got_address_low | load, loc + 4);
> - bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 8);
> - bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
> +
> + if ((elf_elfheader (output_bfd)->e_flags & EF_MIPS_ARCH)
> + == E_MIPS_ARCH_1)
> + {
> + bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 8);
> + bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
> + }
> + else
> + {
> + bfd_put_32 (output_bfd, plt_entry[2], loc + 8);
> + bfd_put_32 (output_bfd, plt_entry[3] | got_address_low, loc + 12);
> + }
>
> /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry. */
> mips_elf_output_dynamic_relocation (output_bfd, htab->srelplt,
I've actually thought of something along the lines of:
plt_entry = mips_exec_plt_entry;
bfd_put_32 (output_bfd, plt_entry[0] | got_address_high, loc);
bfd_put_32 (output_bfd, plt_entry[1] | got_address_low | load, loc + 4);
/* There is no need to keep the load delay slot on non-MIPS1 CPUs,
so reorder the second last instruction into the delay slot of the
trailing jump for efficiency. */
if ((elf_elfheader (output_bfd)->e_flags & EF_MIPS_ARCH)
== E_MIPS_ARCH_1)
{
bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 8);
bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
}
else
{
bfd_put_32 (output_bfd, plt_entry[3], loc + 8);
bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 12);
}
i.e. using the same template and then swap the last two instructions if
possible. Though it's up to Richard to declare whether I am too pedantic.
;)
Thanks for your work!
Maciej