svn commit: r244600 - head/contrib/binutils/bfd
Dimitry Andric
dim at FreeBSD.org
Sat Dec 22 21:00:39 UTC 2012
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 <iostream>
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...]
More information about the svn-src-head
mailing list