* PATCH: Fix the mips dynamic relocation for weak definiton.
@ 2001-08-26 17:49 H . J . Lu
2001-08-27 8:06 ` H . J . Lu
0 siblings, 1 reply; 2+ messages in thread
From: H . J . Lu @ 2001-08-26 17:49 UTC (permalink / raw)
To: binutils
I cannot believe that we didn't catch this bug much earlier. I copied
the same logic in elf_i386_check_relocs (). I also added the missing
prototype. Is that ok to check in?
H.J.
----
2001-08-26 H.J. Lu <hjl@gnu.org>
* elf32-mips.c (mips_elf_create_dynamic_relocation): Add the
sanity check.
(mips_elf_calculate_relocation): Create dynamic relocation for
symbols with weak definition or the ELF_LINK_HASH_DEF_REGULAR
bit is not set.
(_bfd_mips_elf_hide_symbol): Add prototype.
(_bfd_mips_elf_copy_indirect_symbol): Likewise.
(_bfd_elf32_mips_grok_prstatus): Likewise.
(_bfd_elf32_mips_grok_psinfo): Likewise.
(_bfd_mips_elf_hide_symbol): Make it static and cast to
`struct mips_elf_link_hash_entry *'.
(_bfd_mips_elf_copy_indirect_symbol): Make it static.
--- bfd/elf32-mips.c.assert Sun Aug 26 16:05:28 2001
+++ bfd/elf32-mips.c Sun Aug 26 17:26:50 2001
@@ -210,6 +210,15 @@ static boolean mips_elf_stub_section_p
PARAMS ((bfd *, asection *));
static int sort_dynamic_relocs
PARAMS ((const void *, const void *));
+static void _bfd_mips_elf_hide_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static void _bfd_mips_elf_copy_indirect_symbol
+ PARAMS ((struct elf_link_hash_entry *,
+ struct elf_link_hash_entry *));
+static boolean _bfd_elf32_mips_grok_prstatus
+ PARAMS ((bfd *, Elf_Internal_Note *));
+static boolean _bfd_elf32_mips_grok_psinfo
+ PARAMS ((bfd *, Elf_Internal_Note *));
extern const bfd_target bfd_elf32_tradbigmips_vec;
extern const bfd_target bfd_elf32_tradlittlemips_vec;
@@ -3999,14 +4008,16 @@ mips_elf_link_hash_newfunc (entry, table
return (struct bfd_hash_entry *) ret;
}
-void
-_bfd_mips_elf_hide_symbol (info, h)
+static void
+_bfd_mips_elf_hide_symbol (info, entry)
struct bfd_link_info *info;
- struct mips_elf_link_hash_entry *h;
+ struct elf_link_hash_entry *entry;
{
bfd *dynobj;
asection *got;
struct mips_got_info *g;
+ struct mips_elf_link_hash_entry *h;
+ h = (struct mips_elf_link_hash_entry *) entry;
dynobj = elf_hash_table (info)->dynobj;
got = bfd_get_section_by_name (dynobj, ".got");
g = (struct mips_got_info *) elf_section_data (got)->tdata;
@@ -5937,6 +5948,10 @@ mips_elf_create_dynamic_relocation (outp
/* We've now added another relocation. */
++sreloc->reloc_count;
+ /* Sanity check. */
+ BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd)
+ <= sreloc->_raw_size);
+
/* Make sure the output section is writable. The dynamic linker
will be writing to it. */
elf_section_data (input_section->output_section)->this_hdr.sh_flags
@@ -6319,8 +6334,9 @@ mips_elf_calculate_relocation (abfd,
if ((info->shared
|| (elf_hash_table (info)->dynamic_sections_created
&& h != NULL
- && ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
- != 0)))
+ && (h->root.type == bfd_link_hash_defweak
+ || (h->root.elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
&& (input_section->flags & SEC_ALLOC) != 0)
{
/* If we're creating a shared library, or this relocation is
@@ -8065,7 +8081,7 @@ _bfd_mips_elf_gc_sweep_hook (abfd, info,
hiding the old indirect symbol. Process additional relocation
information. */
-void
+static void
_bfd_mips_elf_copy_indirect_symbol (dir, ind)
struct elf_link_hash_entry *dir, *ind;
{
@@ -9170,7 +9186,8 @@ _bfd_elf32_mips_grok_prstatus (abfd, not
raw_size, note->descpos + offset);
}
-static boolean _bfd_elf32_mips_grok_psinfo (abfd, note)
+static boolean
+_bfd_elf32_mips_grok_psinfo (abfd, note)
bfd *abfd;
Elf_Internal_Note *note;
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Fix the mips dynamic relocation for weak definiton.
2001-08-26 17:49 PATCH: Fix the mips dynamic relocation for weak definiton H . J . Lu
@ 2001-08-27 8:06 ` H . J . Lu
0 siblings, 0 replies; 2+ messages in thread
From: H . J . Lu @ 2001-08-27 8:06 UTC (permalink / raw)
To: binutils; +Cc: nickc, echristo
On Sun, Aug 26, 2001 at 05:49:02PM -0700, H . J . Lu wrote:
> I cannot believe that we didn't catch this bug much earlier. I copied
> the same logic in elf_i386_check_relocs (). I also added the missing
> prototype. Is that ok to check in?
>
>
> H.J.
> ----
> 2001-08-26 H.J. Lu <hjl@gnu.org>
>
> * elf32-mips.c (mips_elf_create_dynamic_relocation): Add the
> sanity check.
> (mips_elf_calculate_relocation): Create dynamic relocation for
> symbols with weak definition or the ELF_LINK_HASH_DEF_REGULAR
> bit is not set.
> (_bfd_mips_elf_hide_symbol): Add prototype.
> (_bfd_mips_elf_copy_indirect_symbol): Likewise.
> (_bfd_elf32_mips_grok_prstatus): Likewise.
> (_bfd_elf32_mips_grok_psinfo): Likewise.
> (_bfd_mips_elf_hide_symbol): Make it static and cast to
> `struct mips_elf_link_hash_entry *'.
> (_bfd_mips_elf_copy_indirect_symbol): Make it static.
>
I checked in the prototype part of the patch. Here is an updated patch
for mips dynamic relocation only. I will check it in today as an
obvious fix.
Thanks.
H.J.
----
2001-08-27 H.J. Lu <hjl@gnu.org>
* elf32-mips.c (mips_elf_create_dynamic_relocation): Add more
sanity check.
(mips_elf_calculate_relocation): Create dynamic relocation for
symbols with weak definition or the ELF_LINK_HASH_DEF_REGULAR
bit is not set.
--- bfd/elf32-mips.c.assert Mon Aug 27 07:47:46 2001
+++ bfd/elf32-mips.c Mon Aug 27 07:57:09 2001
@@ -5830,6 +5830,8 @@ mips_elf_create_dynamic_relocation (outp
MIPS_ELF_REL_DYN_SECTION_NAME (output_bfd));
BFD_ASSERT (sreloc != NULL);
BFD_ASSERT (sreloc->contents != NULL);
+ BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd)
+ < sreloc->_raw_size);
skip = false;
@@ -6330,8 +6332,9 @@ mips_elf_calculate_relocation (abfd,
if ((info->shared
|| (elf_hash_table (info)->dynamic_sections_created
&& h != NULL
- && ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
- != 0)))
+ && (h->root.type == bfd_link_hash_defweak
+ || (h->root.elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0)))
&& (input_section->flags & SEC_ALLOC) != 0)
{
/* If we're creating a shared library, or this relocation is
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-08-27 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-26 17:49 PATCH: Fix the mips dynamic relocation for weak definiton H . J . Lu
2001-08-27 8:06 ` H . J . Lu
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).