This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] mips: fix segfault when creating a dso with discarded .dynsym section

An assertion in elfxx-mips.c fails during the creation of the .dynamic
section because it assumes there will always be a .dynsym section present
which may not be true if the .dynsym section was (crazily) discarded.

This adjusts the case for DT_MIPS_SYMTABNO so that it records 0 symbols
if no .dynsym section is present.

* elfxx-mips.c(_bfd_mips_elf_finish_dynamic_sections): fix segfault when
  creating a dso with discarded dynsym section

I discovered this while trying to debug some MIPS testsuite failures.
Looking at the build logs from debian[1], I don't think the testsuite
has passed for over 10 years. I can take a better look at these unless
there's a reason noone's fixed them.



 bfd/elfxx-mips.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e89f089..34a20dd 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -11455,9 +11455,11 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd,
 	      name = ".dynsym";
 	      elemsize = MIPS_ELF_SYM_SIZE (output_bfd);
 	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
-	      dyn.d_un.d_val = s->size / elemsize;
+	      if (s != NULL)
+		dyn.d_un.d_val = s->size / elemsize;
+	      else
+		dyn.d_un.d_val = 0;
 	    case DT_MIPS_HIPAGENO:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]