From 64ea2f800e53d25242d8fb1bfcbcbc249c6303ec Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 22 Dec 2012 20:46:46 +0000 Subject: [PATCH] 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 --- contrib/binutils/bfd/elflink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c index 331ae4fcf625..44973febfa83 100644 --- a/contrib/binutils/bfd/elflink.c +++ b/contrib/binutils/bfd/elflink.c @@ -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;