This is the mail archive of the binutils@sourceware.org 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]

[PATCH] Change MIPS linker stubs to allow for more than 2^15 symbols.


As noted in this thread:

http://sourceware.org/ml/binutils/2006-06/msg00086.html

The mips linker would not reliably allow for more than 2^15 dynamic symbols. This prevents GCC's libgcj java runtime library from being correctly linked.

The consensus was to increase the size of the linker stubs by one instruction so that objects with many dynamic symbols could be supported.

I increased the size of the stub from 16 to 20 bytes. The new stubs support up to 2^31 dynamic symbols. That should be enough for at least the short term. With the patch applied I can now successfully build and run libgcj from a recent GCC-4.2 snapshot on mipsel-linux.

Tested with a mipsel-linux cross build running on i686-pc-linux-gnu with no regressions in the testsuite.

Perhaps someone with a mips64 system could test there, as this patch effects that architecture as well.

Comments?

OK to commit?

How about to the 2.17 branch?

David Daney

bfd:
2006-06-07  David Daney  <ddaney@avtrex.com>

	* elfxx-mips.c (STUB_LI16): Made non sign extending.
	(STUB_LUI): New macro.
	(MIPS_FUNCTION_STUB_SIZE): Increased to 20.
	(_bfd_mips_elf_finish_dynamic_symbol): Changed stub generation
	to allow larger symbol table indexes.
? doc/bfd.info
Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.169
diff -c -p -r1.169 elfxx-mips.c
*** elfxx-mips.c	22 May 2006 15:06:22 -0000	1.169
--- elfxx-mips.c	7 Jun 2006 22:58:04 -0000
*************** static bfd *reldyn_sorting_bfd;
*** 631,642 ****
     ((ABI_64_P (abfd)						\
       ? 0x03e0782d		/* daddu t7,ra */		\
       : 0x03e07821))		/* addu t7,ra */
  #define STUB_JALR 0x0320f809	/* jalr t9,ra */
! #define STUB_LI16(abfd)                                         \
!   ((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
     section.  */
--- 631,640 ----
     ((ABI_64_P (abfd)						\
       ? 0x03e0782d		/* daddu t7,ra */		\
       : 0x03e07821))		/* addu t7,ra */
+ #define STUB_LUI 0x3c180000     /* lui t8,0 */
  #define STUB_JALR 0x0320f809	/* jalr t9,ra */
! #define STUB_LI16 0x34180000	/* ori t8,zero,0 */
! #define MIPS_FUNCTION_STUB_SIZE (20)
  
  /* The name of the dynamic interpreter.  This is put in the .interp
     section.  */
*************** _bfd_mips_elf_finish_dynamic_symbol (bfd
*** 8013,8027 ****
  				   MIPS_ELF_STUB_SECTION_NAME (dynobj));
        BFD_ASSERT (s != NULL);
  
-       /* FIXME: Can h->dynindx be more than 64K?  */
-       if (h->dynindx & 0xffff0000)
- 	return FALSE;
- 
        /* Fill the stub.  */
        bfd_put_32 (output_bfd, STUB_LW (output_bfd), stub);
        bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), stub + 4);
!       bfd_put_32 (output_bfd, STUB_JALR, stub + 8);
!       bfd_put_32 (output_bfd, STUB_LI16 (output_bfd) + h->dynindx, stub + 12);
  
        BFD_ASSERT (h->plt.offset <= s->size);
        memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
--- 8011,8023 ----
  				   MIPS_ELF_STUB_SECTION_NAME (dynobj));
        BFD_ASSERT (s != NULL);
  
        /* Fill the stub.  */
        bfd_put_32 (output_bfd, STUB_LW (output_bfd), stub);
        bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), stub + 4);
!       bfd_put_32 (output_bfd, STUB_LUI + ((h->dynindx >> 16 ) & 0xffff),
!                   stub + 8);
!       bfd_put_32 (output_bfd, STUB_JALR, stub + 12);
!       bfd_put_32 (output_bfd, STUB_LI16 + (h->dynindx & 0xffff), stub + 16);
  
        BFD_ASSERT (h->plt.offset <= s->size);
        memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);

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