From: Mark Mitchell <mark@codesourcery.com>
To: binutils@sourceware.cygnus.com
Cc: "Koundinya K." <kk@ddeorg.soft.net>
Subject: PATCH for elf32-mips.c
Date: Thu, 05 Aug 1999 19:46:00 -0000 [thread overview]
Message-ID: <19990805194952E.mitchell@codesourcery.com> (raw)
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. */
next reply other threads:[~1999-08-05 19:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-05 19:46 Mark Mitchell [this message]
1999-08-07 6:55 ` Koundinya.K
1999-08-07 14:42 ` Ralf Baechle
-- strict thread matches above, loose matches on Subject: below --
2001-06-06 13:45 Patch " H . J . Lu
[not found] <199909251314.GAA16811@crane.prod.itd.earthlink.net>
1999-09-25 9:40 ` patch " Mark Mitchell
1999-09-25 6:14 Felix Lee
1999-09-25 6:14 Felix Lee
1999-08-02 23:07 PATCH " Mark Mitchell
1999-08-03 14:57 ` Ralf Baechle
1999-08-01 15:48 Mark Mitchell
1999-07-01 0:00 mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19990805194952E.mitchell@codesourcery.com \
--to=mark@codesourcery.com \
--cc=binutils@sourceware.cygnus.com \
--cc=kk@ddeorg.soft.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).