From owner-svn-src-all@FreeBSD.ORG Sat Dec 22 21:00:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3B2E85E7; Sat, 22 Dec 2012 21:00:39 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id E264C8FC0A; Sat, 22 Dec 2012 21:00:38 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:84e5:2627:88f9:e626] (unknown [IPv6:2001:7b8:3a7:0:84e5:2627:88f9:e626]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 061B85C5A; Sat, 22 Dec 2012 22:00:38 +0100 (CET) Message-ID: <50D61F79.3070705@FreeBSD.org> Date: Sat, 22 Dec 2012 22:00:41 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20121128 Thunderbird/18.0 MIME-Version: 1.0 To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r244600 - head/contrib/binutils/bfd References: <201212222046.qBMKkkcJ049291@svn.freebsd.org> In-Reply-To: <201212222046.qBMKkkcJ049291@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2012 21:00:39 -0000 On 2012-12-22 21:46, Dimitry Andric wrote: > Author: dim > Date: Sat Dec 22 20:46:46 2012 > New Revision: 244600 > URL: http://svnweb.freebsd.org/changeset/base/244600 > > Log: > Fix a bug in ld --gc-sections: it strips out .note sections, while it > should never do so. This can cause global constructors and destructors > to not be executed at run-time, resulting in crashes and other strange > behaviour. Sample program: #include class Foo { public: Foo() { std::cout << "Foo::Foo()" << std::endl; } ~Foo() { std::cout << "Foo::~Foo()" << std::endl; } }; Foo foo; int main(void) { std::cout << "main()" << std::endl; return 0; } Compiling this normally is fine: $ c++ gctest.cpp -o gctest $ ./gctest Foo::Foo() main() Foo::~Foo() $ readelf -n gctest Notes at offset 0x0000014c with length 0x00000030: Owner Data size Description FreeBSD 0x00000004 NT_VERSION (version) FreeBSD 0x00000004 NT_ARCH (architecture) Linking with --gc-sections makes it crash: $ c++ gctest.cpp -o gctest -Wl,--gc-sections $ ./gctest Segmentation fault (core dumped) $ readelf -n gctest [...no output...]