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
On Mon, Jan 29, 2018 at 3:53 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Jan 29, 2018 at 03:36:05PM -0800, H.J. Lu wrote:
>> There is a reason why I have been keeping asking for a testcase.
>> I will update my patch with the above testcase.
>
> The last few emails in this thread illustrate just why changes based
> on testcases can be suspect.
>
> I don't believe that ld 2.28 or earlier defined dynamic __start and
> __stop symbols without a dynamic reference. In fact, you need to use
> -E or some other way of making symbols dynamic in an executable to
> support dlsym on *normal* symbols. I'm going to commit the extra test
> I posted earlier without -E, plus this patch.
>
> * elflink.c (bfd_elf_define_start_stop): Make __start and __stop
> symbols dynamic.
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index e81f6c6..f1ec880 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -14354,8 +14354,13 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
> bed = get_elf_backend_data (info->output_bfd);
> (*bed->elf_backend_hide_symbol) (info, h, TRUE);
> }
> - else if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
> - h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
> + else
> + {
> + if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
> + h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
> + if (h->ref_dynamic || h->def_dynamic)
> + bfd_elf_link_record_dynamic_symbol (info, h);
> + }
> return &h->root;
> }
> return NULL;
I have a question for your testcase:
diff --git a/ld/testsuite/ld-elf/pr21964-3a.c b/ld/testsuite/ld-elf/pr21964-3a.c
new file mode 100644
index 0000000..835040e
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21964-3a.c
@@ -0,0 +1,11 @@
+extern int __start___verbose[];
+extern int __stop___verbose[];
+int
+foo3 (void)
+{
+ if (__start___verbose == __stop___verbose
+ || __start___verbose[0] != 6)
+ return -1;
+ else
+ return 0;
+}
Which __start___verbose/_start___verbose definition should it
reference at run-time? There are more than one.
--
H.J.