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.

Reported by:	rene
MFC after:	1 week
This commit is contained in:
Dimitry Andric 2012-12-22 20:46:46 +00:00
parent d1ff5f1ee2
commit 64ea2f800e

View File

@ -10584,6 +10584,7 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
{
/* Keep debug and special sections. */
if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0
|| elf_section_data (o)->this_hdr.sh_type == SHT_NOTE
|| (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
o->gc_mark = 1;