* BFD_ASSERT failure in elf32-mips.c with possible fix
@ 1996-08-09 6:46 David S. Miller
1996-08-09 9:44 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: David S. Miller @ 1996-08-09 6:46 UTC (permalink / raw)
To: gas2
The following c-torture case:
extern int abort();
typedef int (*frob)();
frob f[] = {abort};
main()
{
exit(0);
}
Caused GNU ld to fail the assertion on line 5214 in
mips_elf_adjust_dynamic_symbol The following diff make
the problem go away for me, but the fix may not be correct.
*** elf32-mips.c.~1~ Wed Jul 24 16:11:13 1996
--- elf32-mips.c Fri Aug 9 06:31:44 1996
***************
*** 5107,5154 ****
if ((info->shared || h != NULL)
&& (sec->flags & SEC_ALLOC) != 0)
{
! if (info->shared)
{
! /* When creating a shared object, we must copy these
! reloc types into the output file as R_MIPS_REL32
! relocs. We create the .rel.dyn reloc section in
! dynobj and make room for this reloc. */
if (sreloc == NULL)
{
! const char *name = ".rel.dyn";
! sreloc = bfd_get_section_by_name (dynobj, name);
! if (sreloc == NULL)
! {
! sreloc = bfd_make_section (dynobj, name);
! if (sreloc == NULL
! || ! bfd_set_section_flags (dynobj, sreloc,
! (SEC_ALLOC
! | SEC_LOAD
! | SEC_HAS_CONTENTS
! | SEC_IN_MEMORY
! | SEC_READONLY))
! || ! bfd_set_section_alignment (dynobj, sreloc,
! 4))
! return false;
!
! /* Add a null element. */
! sreloc->_raw_size += sizeof (Elf32_External_Rel);
! ++sreloc->reloc_count;
! }
}
-
- sreloc->_raw_size += sizeof (Elf32_External_Rel);
}
- else
- {
- struct mips_elf_link_hash_entry *hmips;
! /* We only need to copy this reloc if the symbol is
! defined in a dynamic object. */
! hmips = (struct mips_elf_link_hash_entry *) h;
! ++hmips->mips_32_relocs;
! }
}
if (SGI_COMPAT (abfd))
--- 5107,5142 ----
if ((info->shared || h != NULL)
&& (sec->flags & SEC_ALLOC) != 0)
{
! /* When creating a shared object, we must copy these
! reloc types into the output file as R_MIPS_REL32
! relocs. We create the .rel.dyn reloc section in
! dynobj and make room for this reloc. */
! if (sreloc == NULL)
{
! const char *name = ".rel.dyn";
!
! sreloc = bfd_get_section_by_name (dynobj, name);
if (sreloc == NULL)
{
! sreloc = bfd_make_section (dynobj, name);
! if (sreloc == NULL
! || ! bfd_set_section_flags (dynobj, sreloc,
! (SEC_ALLOC
! | SEC_LOAD
! | SEC_HAS_CONTENTS
! | SEC_IN_MEMORY
! | SEC_READONLY))
! || ! bfd_set_section_alignment (dynobj, sreloc,
! 4))
! return false;
! /* Add a null element. */
! sreloc->_raw_size += sizeof (Elf32_External_Rel);
! ++sreloc->reloc_count;
}
}
! sreloc->_raw_size += sizeof (Elf32_External_Rel);
}
if (SGI_COMPAT (abfd))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: BFD_ASSERT failure in elf32-mips.c with possible fix
1996-08-09 6:46 BFD_ASSERT failure in elf32-mips.c with possible fix David S. Miller
@ 1996-08-09 9:44 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 1996-08-09 9:44 UTC (permalink / raw)
To: dm; +Cc: gas2
Date: Fri, 9 Aug 1996 06:45:58 -0700
From: "David S. Miller" <dm@neteng.engr.sgi.com>
The following c-torture case:
extern int abort();
typedef int (*frob)();
frob f[] = {abort};
main()
{
exit(0);
}
Thanks for the note. I think this patch is more nearly correct, since
it won't waste space on an unnecessary .rel.dyn section.
I don't consider the dynamic linking code in elf32-mips.c to be
particularly robust. It doesn't even pass the ld testsuite on Irix 5.
Ian
Index: elf32-mips.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elf32-mips.c,v
retrieving revision 1.84
diff -u -r1.84 elf32-mips.c
--- elf32-mips.c 1996/07/24 23:11:13 1.84
+++ elf32-mips.c 1996/08/09 16:42:21
@@ -5107,37 +5107,38 @@
if ((info->shared || h != NULL)
&& (sec->flags & SEC_ALLOC) != 0)
{
+ if (sreloc == NULL)
+ {
+ const char *name = ".rel.dyn";
+
+ sreloc = bfd_get_section_by_name (dynobj, name);
+ if (sreloc == NULL)
+ {
+ sreloc = bfd_make_section (dynobj, name);
+ if (sreloc == NULL
+ || ! bfd_set_section_flags (dynobj, sreloc,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_READONLY))
+ || ! bfd_set_section_alignment (dynobj, sreloc,
+ 4))
+ return false;
+ }
+ }
if (info->shared)
{
/* When creating a shared object, we must copy these
reloc types into the output file as R_MIPS_REL32
- relocs. We create the .rel.dyn reloc section in
- dynobj and make room for this reloc. */
- if (sreloc == NULL)
+ relocs. We make room for this reloc in the
+ .rel.dyn reloc section */
+ if (sreloc->_raw_size == 0)
{
- const char *name = ".rel.dyn";
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc,
- 4))
- return false;
-
- /* Add a null element. */
- sreloc->_raw_size += sizeof (Elf32_External_Rel);
- ++sreloc->reloc_count;
- }
+ /* Add a null element. */
+ sreloc->_raw_size += sizeof (Elf32_External_Rel);
+ ++sreloc->reloc_count;
}
-
sreloc->_raw_size += sizeof (Elf32_External_Rel);
}
else
@@ -5213,6 +5214,12 @@
s = bfd_get_section_by_name (dynobj, ".rel.dyn");
BFD_ASSERT (s != NULL);
+ if (s->_raw_size == 0)
+ {
+ /* Make room for a null element. */
+ s->_raw_size += sizeof (Elf32_External_Rel);
+ ++s->reloc_count;
+ }
s->_raw_size += hmips->mips_32_relocs * sizeof (Elf32_External_Rel);
}
@@ -6085,7 +6092,7 @@
/* Clean up a first relocation in .rel.dyn. */
s = bfd_get_section_by_name (dynobj, ".rel.dyn");
- if (s != NULL)
+ if (s != NULL && s->_raw_size > 0)
memset (s->contents, 0, sizeof (Elf32_External_Rel));
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-08-09 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-09 6:46 BFD_ASSERT failure in elf32-mips.c with possible fix David S. Miller
1996-08-09 9:44 ` Ian Lance Taylor
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).