This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Define __start/__stop symbols when there is only a dynamic def
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>, Michael Matz <matz at suse dot de>, Nick Clifton <nickc at redhat dot com>
- Date: Fri, 26 Jan 2018 04:12:49 -0800
- Subject: Re: Define __start/__stop symbols when there is only a dynamic def
- Authentication-results: sourceware.org; auth=none
- References: <20180126052959.GB20622@bubble.grove.modra.org>
On Thu, Jan 25, 2018 at 9:29 PM, Alan Modra <amodra@gmail.com> wrote:
> This patch fixes a case where a user had a C-representable named
> section in both the executable and shared libraries, and of course
> wanted the size of the local section in the executable, not the
> dynamic section. It does mean that __start and __stop symbols don't
> behave exactly like PROVIDEd symbols, but I think that's a reasonable
> difference particularly since this is the way they used to behave.
>
> Nick, I'd like to apply this to the branch. I think it should be
> quite safe.
>
> * elflink.c (bfd_elf_define_start_stop): Override symbols when
> they are defined dynamically.
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index e3751fa..e81f6c6 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -14338,7 +14338,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
> if (h != NULL
> && (h->root.type == bfd_link_hash_undefined
> || h->root.type == bfd_link_hash_undefweak
> - || (h->ref_regular && !h->def_regular)))
> + || ((h->ref_regular || h->def_dynamic) && !h->def_regular)))
> {
> h->root.type = bfd_link_hash_defined;
> h->root.u.def.section = sec;
>
Can you please add a testcase to verify that your patch does what you intended
and make linker stay this way?
Thanks,
--
H.J.