public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* SH New PLT code
@ 2001-05-15  4:30 kaz Kojima
  2001-05-23  9:42 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: kaz Kojima @ 2001-05-15  4:30 UTC (permalink / raw)
  To: binutils

Hello,

Current SH PLT code uses 3 registers r0, r1 and r2. Since gcc for
SH usually uses r2 to pass the address of the returned structure to
the large structure valued function. So such function doesn't work
in shared library.

The attached patch is new PLT codes using r0, r1 only. SH PIC ABI
says that r0 shows the type of PLT, r1 the offset into relocation
table and r2 GOT id. It says also that PLT code can be optimized.
The new PLT codes use r0 as the GOT id. Fortunately, since the type
of PLT is currently 0 or 8 in SH PIC ABI and the first 3 entries of
GOT never used from PLT i.e. GOT id >= 12, we can use r0 as GOT id
and this can be regarded as an optimization of PLT. The resolver
can easily detect which type of PLT is used with looking r0. So
the mixture of old and new binaries is not so problem.

BTW, The needed change of the dynamic linker is very tiny. If this
patch is ok, I'll sent the patch to the SH specific resolver code
of GNU libc to the libc-hackers.

Regards,
	kaz
--
2001-05-14  kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* elf32-sh.c (elf_sh_plt0_entry_be, elf_sh_plt0_entry,
	elf_sh_plt_entry_be, elf_sh_plt_entry, elf_sh_pic_plt_entry_be,
	elf_sh_pic_plt_entry): New PLT code.

Index: elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.28
diff -u -r1.28 elf32-sh.c
--- elf32-sh.c	2001/03/13 04:43:40	1.28
+++ elf32-sh.c	2001/05/13 22:17:58
@@ -2093,13 +2093,13 @@
 
 static const bfd_byte elf_sh_plt0_entry_be[PLT_ENTRY_SIZE] =
 {
-  0xd0, 0x04,	/* mov.l 1f,r0 */
-  0xd2, 0x05,	/* mov.l 2f,r2 */
+  0xd0, 0x05,	/* mov.l 2f,r0 */
+  0x60, 0x02,	/* mov.l @r0,r0 */
+  0x2f, 0x06,	/* mov.l r0,@-r15 */
+  0xd0, 0x03,	/* mov.l 1f,r0 */
   0x60, 0x02,	/* mov.l @r0,r0 */
-  0x62, 0x22,	/* mov.l @r2,r2 */
   0x40, 0x2b,	/* jmp @r0 */
-  0xe0, 0x00,	/*  mov #0,r0 */
-  0x00, 0x09,	/* nop */
+  0x60, 0xf6,	/*  mov.l @r15+,r0 */
   0x00, 0x09,	/* nop */
   0x00, 0x09,	/* nop */
   0x00, 0x09,	/* nop */
@@ -2109,13 +2109,13 @@
 
 static const bfd_byte elf_sh_plt0_entry_le[PLT_ENTRY_SIZE] =
 {
-  0x04, 0xd0,	/* mov.l 1f,r0 */
-  0x05, 0xd2,	/* mov.l 2f,r2 */
+  0x05, 0xd0,	/* mov.l 2f,r0 */
+  0x02, 0x60,	/* mov.l @r0,r0 */
+  0x06, 0x2f,	/* mov.l r0,@-r15 */
+  0x03, 0xd0,	/* mov.l 1f,r0 */
   0x02, 0x60,	/* mov.l @r0,r0 */
-  0x22, 0x62,	/* mov.l @r2,r2 */
   0x2b, 0x40,	/* jmp @r0 */
-  0x00, 0xe0,	/*  mov #0,r0 */
-  0x09, 0x00,	/* nop */
+  0xf6, 0x60,	/*  mov.l @r15+,r0 */
   0x09, 0x00,	/* nop */
   0x09, 0x00,	/* nop */
   0x09, 0x00,	/* nop */
@@ -2130,9 +2130,9 @@
 {
   0xd0, 0x04,	/* mov.l 1f,r0 */
   0x60, 0x02,	/* mov.l @r0,r0 */
-  0xd2, 0x02,	/* mov.l 0f,r2 */
+  0xd1, 0x02,	/* mov.l 0f,r1 */
   0x40, 0x2b,   /* jmp @r0 */
-  0x60, 0x23,	/*  mov r2,r0 */
+  0x60, 0x13,	/*  mov r1,r0 */
   0xd1, 0x03,	/* mov.l 2f,r1 */
   0x40, 0x2b,	/* jmp @r0 */
   0x00, 0x09,	/* nop */
@@ -2145,13 +2145,13 @@
 {
   0x04, 0xd0,	/* mov.l 1f,r0 */
   0x02, 0x60,	/* mov.l @r0,r0 */
-  0x02, 0xd2,	/* mov.l 0f,r2 */
+  0x02, 0xd1,	/* mov.l 0f,r1 */
   0x2b, 0x40,   /* jmp @r0 */
-  0x23, 0x60,	/*  mov r2,r0 */
+  0x13, 0x60,	/*  mov r1,r0 */
   0x03, 0xd1,	/* mov.l 2f,r1 */
   0x2b, 0x40,	/* jmp @r0 */
   0x09, 0x00,	/*  nop */
-  0, 0, 0, 0,	/* 0: replaced with address of .PLT.  */
+  0, 0, 0, 0,	/* 0: replaced with address of .PLT0.  */
   0, 0, 0, 0,	/* 1: replaced with address of this symbol in .got.  */
   0, 0, 0, 0,	/* 2: replaced with offset into relocation table.  */
 };
@@ -2164,11 +2164,11 @@
   0x00, 0xce,	/* mov.l @(r0,r12),r0 */
   0x40, 0x2b,	/* jmp @r0 */
   0x00, 0x09,	/*  nop */
-  0x50, 0xc2,	/* 0: mov.l @(8,r12),r0 */
-  0x52, 0xc1,	/* 1: mov.l @(4,r12),r2 */
-  0xd1, 0x02,	/* mov.l 2f,r1 */
+  0x50, 0xc2,	/* mov.l @(8,r12),r0 */
+  0xd1, 0x03,	/* mov.l 2f,r1 */
   0x40, 0x2b,	/* jmp @r0 */
-  0xe0, 0x00,	/*  mov #0,r0 ! shows the type of PLT.  */
+  0x50, 0xc1,	/*  mov.l @(4,r12),r0 */
+  0x00, 0x09,	/* nop */
   0x00, 0x09,	/* nop */
   0, 0, 0, 0,	/* 1: replaced with address of this symbol in .got.  */
   0, 0, 0, 0    /* 2: replaced with offset into relocation table.  */
@@ -2180,11 +2180,11 @@
   0xce, 0x00,	/* mov.l @(r0,r12),r0 */
   0x2b, 0x40,	/* jmp @r0 */
   0x09, 0x00,	/*  nop */
-  0xc2, 0x50,	/* 0: mov.l @(8,r12),r0 */
-  0xc1, 0x52,	/* 1: mov.l @(4,r12),r2 */
-  0x02, 0xd1,	/* mov.l 2f,r1 */
+  0xc2, 0x50,	/* mov.l @(8,r12),r0 */
+  0x03, 0xd1,	/* mov.l 2f,r1 */
   0x2b, 0x40,	/* jmp @r0 */
-  0x00, 0xe0,	/*  mov #0,r0 ! shows the type of PLT.  */
+  0xc1, 0x50,	/*  mov.l @(4,r12),r0 */
+  0x09, 0x00,	/*  nop */
   0x09, 0x00,	/* nop */
   0, 0, 0, 0,	/* 1: replaced with address of this symbol in .got.  */
   0, 0, 0, 0    /* 2: replaced with offset into relocation table.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: SH New PLT code
  2001-05-15  4:30 SH New PLT code kaz Kojima
@ 2001-05-23  9:42 ` Nick Clifton
  2001-05-23 15:28   ` kaz Kojima
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2001-05-23  9:42 UTC (permalink / raw)
  To: kaz Kojima; +Cc: binutils

Hi Kaz,

> The attached patch is new PLT codes using r0, r1 only. SH PIC ABI
> says that r0 shows the type of PLT, r1 the offset into relocation
> table and r2 GOT id.

Thanks very much for submitting this patch.  No-one has posted any
objections to it, so I have approved it and applied it to the sources.

Note - I made two changes to the patch.  I added a comment at the
start, explaining why the PLT entries have changed, and I kept the old
PLT entries (but commented out), in case the patch raises problems and
we need to go back to the old method.

> BTW, The needed change of the dynamic linker is very tiny. If this
> patch is ok, I'll sent the patch to the SH specific resolver code
> of GNU libc to the libc-hackers.

Please do this.

> 2001-05-14  kaz Kojima  <kkojima@rr.iij4u.or.jp>
> 
> 	* elf32-sh.c (elf_sh_plt0_entry_be, elf_sh_plt0_entry,
> 	elf_sh_plt_entry_be, elf_sh_plt_entry, elf_sh_pic_plt_entry_be,
> 	elf_sh_pic_plt_entry): New PLT code.

Approved and applied.

Cheers
        Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: SH New PLT code
  2001-05-23  9:42 ` Nick Clifton
@ 2001-05-23 15:28   ` kaz Kojima
  0 siblings, 0 replies; 3+ messages in thread
From: kaz Kojima @ 2001-05-23 15:28 UTC (permalink / raw)
  To: binutils

Hi,

>> BTW, The needed change of the dynamic linker is very tiny. If this
>> patch is ok, I'll sent the patch to the SH specific resolver code
>> of GNU libc to the libc-hackers.
> 
> Please do this.

I'll post it ASAP.

>> 2001-05-14  kaz Kojima  <kkojima@rr.iij4u.or.jp>
>> 
>> 	* elf32-sh.c (elf_sh_plt0_entry_be, elf_sh_plt0_entry,
>> 	elf_sh_plt_entry_be, elf_sh_plt_entry, elf_sh_pic_plt_entry_be,
>> 	elf_sh_pic_plt_entry): New PLT code.
>
> Approved and applied.

Thanks!
	kaz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-23 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-15  4:30 SH New PLT code kaz Kojima
2001-05-23  9:42 ` Nick Clifton
2001-05-23 15:28   ` kaz Kojima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).