From b35e008e3905fcf870391beb33fe9529ab741f2f Mon Sep 17 00:00:00 2001 From: dim Date: Mon, 7 Mar 2016 07:49:01 +0000 Subject: [PATCH] MFC r295901: Fix a problem in ld, causing it to sometimes print messages similar to "invalid string offset 65521 >= 27261 for section `.strtab'". for object files produced by recent versions of clang. In BFD's elf_create_symbuf() function, the size of the symbol buffer ('ssymbuf') is not calculated correctly, and the initial value for the 'ssym' variable is off by one, since 'ssymbuf' has shndx_count + 1 members. git-svn-id: svn://svn.freebsd.org/base/stable/10@296437 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/binutils/bfd/elf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/binutils/bfd/elf.c b/contrib/binutils/bfd/elf.c index bbf1617bd..ed09cb51c 100644 --- a/contrib/binutils/bfd/elf.c +++ b/contrib/binutils/bfd/elf.c @@ -8934,14 +8934,14 @@ elf_create_symbuf (bfd_size_type symcount, Elf_Internal_Sym *isymbuf) shndx_count++; ssymbuf = bfd_malloc ((shndx_count + 1) * sizeof (*ssymbuf) - + (indbufend - indbuf) * sizeof (*ssymbuf)); + + (indbufend - indbuf) * sizeof (*ssym)); if (ssymbuf == NULL) { free (indbuf); return NULL; } - ssym = (struct elf_symbuf_symbol *) (ssymbuf + shndx_count); + ssym = (struct elf_symbuf_symbol *) (ssymbuf + shndx_count + 1); ssymbuf->ssym = NULL; ssymbuf->count = shndx_count; ssymbuf->st_shndx = 0; -- 2.45.0