[PATCH] Always keep sections marked with SEC_KEEP
Alan Modra
amodra@gmail.com
Thu Oct 22 23:52:00 GMT 2015
On Thu, Oct 22, 2015 at 12:24:53PM -0700, H.J. Lu wrote:
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index 73fe469..06df821 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -12449,7 +12449,8 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info)
> o->gc_mark = first->gc_mark;
> }
>
> - if (o->gc_mark)
> + /* Always keep sections marked with SEC_KEEP. */
> + if (o->gc_mark || (o->flags & SEC_KEEP))
> continue;
>
> /* Skip sweeping sections already excluded. */
This is wrong. You're breaking the gc-sections model (and ignoring
the special combination of both SEC_EXCLUDE and SEC_KEEP). Sections
with SEC_KEEP are supposed to have gc_mark set by the call to
_bfd_elf_gc_mark in bfd_elf_gc_sections.
Hmm, actually the underlying problem is your PR11133 patch.
_bfd_elf_gc_mark_rsec 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 --git a/bfd/elflink.c b/bfd/elflink.c
index 2ed07e0..0bec93d 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12109,7 +12109,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;
@@ -12457,8 +12457,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. */
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list