From owner-svn-src-head@FreeBSD.ORG Mon Dec 22 16:31:10 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5D7E6A3F; Mon, 22 Dec 2014 16:31:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49E2264265; Mon, 22 Dec 2014 16:31:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBMGVAfr022773; Mon, 22 Dec 2014 16:31:10 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBMGVAJM022757; Mon, 22 Dec 2014 16:31:10 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201412221631.sBMGVAJM022757@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 22 Dec 2014 16:31:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276061 - head/contrib/elftoolchain/elfcopy X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Dec 2014 16:31:10 -0000 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