This is the mail archive of the binutils@sourceware.org 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.

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

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.

Thanks,
James

[1] https://buildd.debian.org/status/logs.php?pkg=binutils&arch=mipsel&suite=sid

 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;
 	      break;
 
 	    case DT_MIPS_HIPAGENO:
-- 
2.1.1

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