public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH for GOT16 handling
@ 1999-08-09 15:48 Mark Mitchell
  1999-08-09 17:31 ` Ralf Baechle
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Mitchell @ 1999-08-09 15:48 UTC (permalink / raw)
  To: binutils

Ralf and I jointly discovered that elf32-mips.c has historically lied
about the source mask for GOT16/CALL16 entries.  Since the new code
cares, that was causing problems.  Fixed here.  

Also fixed is a problem with looking for matching GOT16 entries in the
GOT.

Coming soon is a patch for the creation of dynamic relocations.  It
looks like the old code got the cases used in the N32 ABI wrong, while
the new code gets the old cases wrong.  Ian and I have hashed out the
right solution; I will implement it.

Ian, did you get a chance to review the elflink.h patch I sent in
about a week ago?  It was designed to avoid wasting relocation entries
in the case that both REL and RELA relocations appear for a single
section.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-08-09  Mark Mitchell  <mark@codesourcery.com>

	* elf32-mips.c (elf_mips_howto_table): Fix src_mask for
	R_MIPS_GOT16 and R_MIPS_CALL16.
	(mips_elf_got16_entry): Use mips_elf_high to calculate the value
	to use wheen looking for a preexisting GOT entry.

Index: elf32-mips.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v
retrieving revision 1.45
diff -c -p -r1.45 elf32-mips.c
*** elf32-mips.c	1999/08/06 02:44:41	1.45
--- elf32-mips.c	1999/08/09 22:41:09
*************** static reloc_howto_type elf_mips_howto_t
*** 602,608 ****
  	 _bfd_mips_elf_got16_reloc,	/* special_function */
  	 "R_MIPS_GOT16",	/* name */
  	 false,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xffff,		/* dst_mask */
  	 false),		/* pcrel_offset */
  
--- 602,608 ----
  	 _bfd_mips_elf_got16_reloc,	/* special_function */
  	 "R_MIPS_GOT16",	/* name */
  	 false,			/* partial_inplace */
! 	 0xffff,		/* src_mask */
  	 0xffff,		/* dst_mask */
  	 false),		/* pcrel_offset */
  
*************** static reloc_howto_type elf_mips_howto_t
*** 632,638 ****
  	 bfd_elf_generic_reloc,	/* special_function */
  	 "R_MIPS_CALL16",	/* name */
  	 false,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xffff,		/* dst_mask */
  	 false),		/* pcrel_offset */
  
--- 632,638 ----
  	 bfd_elf_generic_reloc,	/* special_function */
  	 "R_MIPS_CALL16",	/* name */
  	 false,			/* partial_inplace */
! 	 0xffff,		/* src_mask */
  	 0xffff,		/* dst_mask */
  	 false),		/* pcrel_offset */
  
*************** mips_elf_got16_entry (abfd, info, value)
*** 5537,5543 ****
    bfd_vma index;
    bfd_vma address;
  
!   value &= 0xffff0000;
    g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
  
    /* Look to see if we already have an appropriate entry.  */
--- 5537,5547 ----
    bfd_vma index;
    bfd_vma address;
  
!   /* Although the ABI says that it is "the high-order 16 bits" that we
!      want, it is really the %high value.  The complete value is
!      calculated with a `addiu' of a LO16 relocation, just as with a
!      HI16/LO16 pair.  */
!   value = mips_elf_high (value);
    g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
  
    /* Look to see if we already have an appropriate entry.  */

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

* Re: PATCH for GOT16 handling
  1999-08-09 15:48 PATCH for GOT16 handling Mark Mitchell
@ 1999-08-09 17:31 ` Ralf Baechle
  1999-08-09 20:12   ` Mark Mitchell
  1999-08-09 20:20   ` Mark Mitchell
  0 siblings, 2 replies; 4+ messages in thread
From: Ralf Baechle @ 1999-08-09 17:31 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: binutils

On Mon, Aug 09, 1999 at 03:52:31PM -0700, Mark Mitchell wrote:

> Also fixed is a problem with looking for matching GOT16 entries in the
> GOT.

> 	(mips_elf_got16_entry): Use mips_elf_high to calculate the value
> 	to use wheen looking for a preexisting GOT entry.

> *************** mips_elf_got16_entry (abfd, info, value)
> *** 5537,5543 ****
>     bfd_vma index;
>     bfd_vma address;
>   
> !   value &= 0xffff0000;
>     g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
>   
>     /* Look to see if we already have an appropriate entry.  */
> --- 5537,5547 ----
>     bfd_vma index;
>     bfd_vma address;
>   
> !   /* Although the ABI says that it is "the high-order 16 bits" that we
> !      want, it is really the %high value.  The complete value is
> !      calculated with a `addiu' of a LO16 relocation, just as with a
> !      HI16/LO16 pair.  */
> !   value = mips_elf_high (value);
>     g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
>   
>     /* Look to see if we already have an appropriate entry.  */

This is broken, try test case #11 which will show you a bad got.  The
correct fix is to just add change the mips_elf_high() line into
value += 0x8000.

  Ralf

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

* Re: PATCH for GOT16 handling
  1999-08-09 17:31 ` Ralf Baechle
@ 1999-08-09 20:12   ` Mark Mitchell
  1999-08-09 20:20   ` Mark Mitchell
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 1999-08-09 20:12 UTC (permalink / raw)
  To: ralf; +Cc: binutils

I thought you already tested this patch, and agreed that it worked?
I'll check your test-case.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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

* Re: PATCH for GOT16 handling
  1999-08-09 17:31 ` Ralf Baechle
  1999-08-09 20:12   ` Mark Mitchell
@ 1999-08-09 20:20   ` Mark Mitchell
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 1999-08-09 20:20 UTC (permalink / raw)
  To: ralf; +Cc: binutils

I see it.  My bad.
--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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

end of thread, other threads:[~1999-08-09 20:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-09 15:48 PATCH for GOT16 handling Mark Mitchell
1999-08-09 17:31 ` Ralf Baechle
1999-08-09 20:12   ` Mark Mitchell
1999-08-09 20:20   ` Mark Mitchell

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).