This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
PATCH for elf32-mips.c
- To: binutils@sourceware.cygnus.com
- Subject: PATCH for elf32-mips.c
- From: Mark Mitchell <mark@codesourcery.com>
- Date: Thu, 05 Aug 1999 19:49:52 -0700
- Cc: "Koundinya K." <kk@ddeorg.soft.net>
- Organization: CodeSourcery, LLC
This patch repairs some bain dramage. Ralf reports much improved
results with this patch. I'm working through some other issues, with
help from Ian.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-08-04 Mark Mitchell <mark@codesourcery.com>
* elf32-mips.c (mips_elf_got16_entry): Don't multiply GOT index by
the size of a GOT entry here.
(mips_elf_calculate_relocation): Don't create a local GOT entry
for the symbol in a GOT16 relocation; just for it's high-order bit
(_bfd_mips_elf_relocate_section): Fix thinko.
Index: elf32-mips.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v
retrieving revision 1.44
diff -c -p -r1.44 elf32-mips.c
*** elf32-mips.c 1999/08/04 16:32:34 1.44
--- elf32-mips.c 1999/08/05 05:50:36
*************** mips_elf_got16_entry (abfd, info, value)
*** 5551,5557 ****
if ((address & 0xffff0000) == value)
{
/* This entry has the right high-order 16 bits. */
! index = MIPS_ELF_GOT_SIZE (abfd) * (entry - sgot->contents);
break;
}
}
--- 5551,5557 ----
if ((address & 0xffff0000) == value)
{
/* This entry has the right high-order 16 bits. */
! index = entry - sgot->contents;
break;
}
}
*************** mips_elf_calculate_relocation (abfd,
*** 5971,5983 ****
case R_MIPS_GOT_LO16:
case R_MIPS_CALL_LO16:
/* Find the index into the GOT where this value is located. */
! if (h)
{
BFD_ASSERT (addend == 0);
g = mips_elf_global_got_index
(elf_hash_table (info)->dynobj,
(struct elf_link_hash_entry*) h);
}
else
{
g = mips_elf_local_got_index (abfd, info, symbol + addend);
--- 5971,5987 ----
case R_MIPS_GOT_LO16:
case R_MIPS_CALL_LO16:
/* Find the index into the GOT where this value is located. */
! if (!local_p)
{
BFD_ASSERT (addend == 0);
g = mips_elf_global_got_index
(elf_hash_table (info)->dynobj,
(struct elf_link_hash_entry*) h);
}
+ else if (r_type == R_MIPS_GOT16)
+ /* There's no need to create a local GOT entry here; the
+ calculation for a local GOT16 entry does not involve G. */
+ break;
else
{
g = mips_elf_local_got_index (abfd, info, symbol + addend);
*************** _bfd_mips_elf_relocate_section (output_b
*** 6599,6622 ****
/* There's nothing to do for non-local relocations. */
continue;
- r_symndx = ELF32_R_SYM (rel->r_info);
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- /* Adjust the addend appropriately. */
- addend += local_sections[r_symndx]->output_offset;
-
if (r_type == R_MIPS16_GPREL
|| r_type == R_MIPS_GPREL16
|| r_type == R_MIPS_GPREL32)
addend -= (_bfd_get_gp_value (output_bfd)
- _bfd_get_gp_value (input_bfd));
! else if (r_type == R_MIPS16_26 || r_type == R_MIPS16_26)
/* The addend is stored without its two least
significant bits (which are always zero.) In a
non-relocateable link, calculate_relocation will do
this shift; here, we must do it ourselves. */
addend <<= 2;
/* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16,
then we only want to write out the high-order 16 bits.
The subsequent R_MIPS_LO16 will handle the low-order bits. */
--- 6603,6626 ----
/* There's nothing to do for non-local relocations. */
continue;
if (r_type == R_MIPS16_GPREL
|| r_type == R_MIPS_GPREL16
|| r_type == R_MIPS_GPREL32)
addend -= (_bfd_get_gp_value (output_bfd)
- _bfd_get_gp_value (input_bfd));
! else if (r_type == R_MIPS_26 || r_type == R_MIPS16_26)
/* The addend is stored without its two least
significant bits (which are always zero.) In a
non-relocateable link, calculate_relocation will do
this shift; here, we must do it ourselves. */
addend <<= 2;
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ /* Adjust the addend appropriately. */
+ addend += local_sections[r_symndx]->output_offset;
+
/* If the relocation is for a R_MIPS_HI16 or R_MIPS_GOT16,
then we only want to write out the high-order 16 bits.
The subsequent R_MIPS_LO16 will handle the low-order bits. */