Author: emaste
Date: Mon Dec 22 16:31:09 2014
New Revision: 276061
URL: https://svnweb.freebsd.org/changeset/base/276061

Log:
  Set up default shstrtab entries at shstrtab initialization
  
  Instead of waiting until the addition of the first non-default entry.
  This fixes a segfault when strip(1) is asked to remove every section from
  an object file.
  
  Upstream elftoolchain ticket 463
  
  Reviewed by:  imp
  Sponsored by: The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D1341

Modified:
  head/contrib/elftoolchain/elfcopy/sections.c

Modified: head/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- head/contrib/elftoolchain/elfcopy/sections.c        Mon Dec 22 16:29:15 
2014        (r276060)
+++ head/contrib/elftoolchain/elfcopy/sections.c        Mon Dec 22 16:31:09 
2014        (r276061)
@@ -1139,12 +1139,6 @@ add_to_shstrtab(struct elfcopy *ecp, con
        struct section *s;
 
        s = ecp->shstrtab;
-       if (s->buf == NULL) {
-               insert_to_strtab(s, "");
-               insert_to_strtab(s, ".symtab");
-               insert_to_strtab(s, ".strtab");
-               insert_to_strtab(s, ".shstrtab");
-       }
        insert_to_strtab(s, name);
 }
 
@@ -1206,6 +1200,11 @@ init_shstrtab(struct elfcopy *ecp)
        s->loadable = 0;
        s->type = SHT_STRTAB;
        s->vma = 0;
+
+       insert_to_strtab(s, "");
+       insert_to_strtab(s, ".symtab");
+       insert_to_strtab(s, ".strtab");
+       insert_to_strtab(s, ".shstrtab");
 }
 
 void
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to