This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: STUB_MOVE in elfxx-mips.c
- From: Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de>
- To: binutils at sources dot redhat dot com
- Date: Wed, 1 Oct 2003 16:44:31 +0200
- Subject: Re: STUB_MOVE in elfxx-mips.c
- References: <20031001.231337.59463307.anemo@mba.ocn.ne.jp>
Atsushi Nemoto wrote:
> I found following codes in bfd/elfxx-mips.c:
>
> #define STUB_MOVE(abfd) \
> (SGI_COMPAT (abfd) ? 0x03e07825 : 0x03e07821) /* move t7,ra */
>
> 0x03e07825 is "OR $15,$31,$0" and 0x03e07821 is "ADDU $15,$31,$0".
>
> Why SGI_COMPAT() is used here?
Probably because it mimics what the SGI toolchain for N64 did.
AFAICS it should be API_64_P instead, and it's better to use
'daddu' instead of 'or', as this helps CPUs with several adders.
> The ADDU can not be used to copy 64bit register because the result is
> sign-extended value of the low 32bit of the source register. So OR
> must be used for 64bit ABI, right? Or using OR unconditionally is
> enough, isn't it? Or am I missing something?
I'm surprised it doesn't crash spectacularily. The whole stup definitions
should IMHO read as:
diff -burpNX /bigdisk/src/gcc-exclude source-orig/bfd/elfxx-mips.c source/bfd/elfxx-mips.c
--- source-orig/bfd/elfxx-mips.c Wed Oct 1 02:15:44 2003
+++ source/bfd/elfxx-mips.c Wed Oct 1 16:35:02 2003
@@ -587,17 +588,20 @@ static bfd *reldyn_sorting_bfd;
offsets from $gp. */
#define MIPS_ELF_GOT_MAX_SIZE(abfd) (ELF_MIPS_GP_OFFSET(abfd) + 0x7fff)
-/* Instructions which appear in a stub. For some reason the stub is
- slightly different on an SGI system. */
+/* Instructions which appear in a stub. */
#define STUB_LW(abfd) \
((ABI_64_P (abfd) \
? 0xdf998010 /* ld t9,0x8010(gp) */ \
: 0x8f998010)) /* lw t9,0x8010(gp) */
#define STUB_MOVE(abfd) \
- (SGI_COMPAT (abfd) ? 0x03e07825 : 0x03e07821) /* move t7,ra */
-#define STUB_JALR 0x0320f809 /* jal t9 */
+ ((ABI_64_P (abfd) \
+ ? 0x03e0782d /* daddu t7,ra */ \
+ : 0x03e07821)) /* addu t7,ra */
+#define STUB_JALR 0x0320f809 /* jalr t9,ra */
#define STUB_LI16(abfd) \
- (SGI_COMPAT (abfd) ? 0x34180000 : 0x24180000) /* ori t8,zero,0 */
+ ((ABI_64_P (abfd) \
+ ? 0x64180000 /* daddiu t8,zero,0 */ \
+ : 0x24180000)) /* addiu t8,zero,0 */
#define MIPS_FUNCTION_STUB_SIZE (16)
/* The name of the dynamic interpreter. This is put in the .interp
Beware, this patch is untested.
Thiemo