This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] ELF: Resolve referenced __start_XXX/__stop_XXX symbols
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 9 Jun 2017 17:08:12 -0700
- Subject: Re: [PATCH] ELF: Resolve referenced __start_XXX/__stop_XXX symbols
- Authentication-results: sourceware.org; auth=none
- References: <20170609220526.GA24413@gmail.com>
On Fri, Jun 9, 2017 at 3:05 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Normally, linker will define __start_XXX/__stop_XXX symbols only for
> orphaned sections. However, during garbage collection, ELF linker
> marks all sections with references to __start_XXX/__stop_XXX symbols
> as used. When section XXX isn't an orphaned section, __start_XXX and
> __stop_XXX symbols are left undefined even if section XXX does exist.
> This patch adds SEC_ELF_NEED_START_STOP to section flags to indicate
> that __start_XXX and/or __stop_XXX symbols should be defined and avoid
> defining them as orphaned section. Instead, ELF linker resolves
> references to __start_XXX/__stop_XXX symbols together with .startof.
> symbol.
>
> OK for master?
>
>
> H.J.
> ---
> bfd/
>
> PR ld/21562
> * elflink.c (_bfd_elf_gc_mark_rsec): Set SEC_ELF_NEED_START_STOP
> if a section references __start_XXX/__stop_XXX symbols.
> * section (SEC_ELF_NEED_START_STOP): New.
> * bfd-in2.h: Regenerated.
>
> ld/
>
> PR ld/21562
> * ldlang.c (lang_insert_orphan): Don't define __start_XXX nor
> __stop_XXX symbols for ELF linker if SEC_ELF_NEED_START_STOP is
> set.
> (lang_set_startof): Resolve references to __start_XXX and
> __stop_XXX symbols for ELF linker if SEC_ELF_NEED_START_STOP is
> set.
> * testsuite/ld-elf/pr21557.t: New test.
> * testsuite/ld-elf/pr21557a.d: Likewise.
> * testsuite/ld-elf/pr21557a.s: Likewise.
> * testsuite/ld-elf/pr21557b.d: Likewise.
> * testsuite/ld-elf/pr21557b.s: Likewise.
> * testsuite/ld-elf/pr21557c.d: Likewise.
> * testsuite/ld-elf/pr21557d.d: Likewise.
>
Please ignore this patch. There are more issues:
https://sourceware.org/bugzilla/show_bug.cgi?id=20022
https://sourceware.org/bugzilla/show_bug.cgi?id=19167
H.J.