This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] mips: fix segfault when creating a dso with discarded .dynsym section
- From: James Cowgill <James dot Cowgill at imgtec dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 4 Nov 2014 15:33:59 +0000
- Subject: [PATCH] mips: fix segfault when creating a dso with discarded .dynsym section
- Authentication-results: sourceware.org; auth=none
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