This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Re: Always keep sections marked with SEC_KEEP
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 22 Oct 2015 23:53:00 -0000
- Subject: [binutils-gdb] Re: Always keep sections marked with SEC_KEEP
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1e7eae0dcc0e5473dda573b30107ffdd501b0d73
commit 1e7eae0dcc0e5473dda573b30107ffdd501b0d73
Author: Alan Modra <amodra@gmail.com>
Date: Fri Oct 23 10:14:51 2015 +1030
Re: Always keep sections marked with SEC_KEEP
Revert bba037e0, it breaks the gc-sections model. Instead fix the
underlying problem which is that _bfd_elf_gc_mark_hook is too late to
be setting SEC_KEEP.
PR ld/11133
PR ld/19161
* elflink.c (elf_gc_sweep): Revert last patch.
(_bfd_elf_gc_mark_hook): Don't set SEC_KEEP here.
Diff:
---
bfd/ChangeLog | 7 +++++++
bfd/elflink.c | 5 ++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 60b79ed..481d972 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-23 Alan Modra <amodra@gmail.com>
+
+ PR ld/11133
+ PR ld/19161
+ * elflink.c (elf_gc_sweep): Revert last patch.
+ (_bfd_elf_gc_mark_hook): Don't set SEC_KEEP here.
+
2015-10-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19161
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 06df821..6dcc431 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12101,7 +12101,7 @@ _bfd_elf_gc_mark_hook (asection *sec,
{
sec = bfd_get_section_by_name (i, sec_name);
if (sec)
- sec->flags |= SEC_KEEP;
+ return sec;
}
}
break;
@@ -12449,8 +12449,7 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
o->gc_mark = first->gc_mark;
}
- /* Always keep sections marked with SEC_KEEP. */
- if (o->gc_mark || (o->flags & SEC_KEEP))
+ if (o->gc_mark)
continue;
/* Skip sweeping sections already excluded. */