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]

SH New PLT code


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.  */


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