Check if __start/__stop symbols are referenced by shared objects
Define __start/__stop symbols if they are referenced by shared objects, not if they are also defined in shared objects. bfd/ PR ld/21964 * elflink.c (bfd_elf_define_start_stop): Check if __start and __stop symbols are referenced by shared objects. ld/ PR ld/21964 * testsuite/ld-elf/pr21964-4.c: New file. * testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.
This commit is contained in:
parent
bea298f954
commit
823143c6ca
|
@ -1,3 +1,9 @@
|
||||||
|
2018-01-31 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/21964
|
||||||
|
* elflink.c (bfd_elf_define_start_stop): Check if __start and
|
||||||
|
__stop symbols are referenced by shared objects.
|
||||||
|
|
||||||
2018-01-30 Alan Modra <amodra@gmail.com>
|
2018-01-30 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 22758
|
PR 22758
|
||||||
|
|
|
@ -14338,7 +14338,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
|
||||||
if (h != NULL
|
if (h != NULL
|
||||||
&& (h->root.type == bfd_link_hash_undefined
|
&& (h->root.type == bfd_link_hash_undefined
|
||||||
|| h->root.type == bfd_link_hash_undefweak
|
|| h->root.type == bfd_link_hash_undefweak
|
||||||
|| ((h->ref_regular || h->def_dynamic) && !h->def_regular)))
|
|| ((h->ref_regular || h->ref_dynamic) && !h->def_regular)))
|
||||||
{
|
{
|
||||||
h->root.type = bfd_link_hash_defined;
|
h->root.type = bfd_link_hash_defined;
|
||||||
h->root.u.def.section = sec;
|
h->root.u.def.section = sec;
|
||||||
|
@ -14358,7 +14358,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
|
||||||
{
|
{
|
||||||
if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
||||||
h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
|
h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
|
||||||
if (h->ref_dynamic || h->def_dynamic)
|
if (h->ref_dynamic)
|
||||||
bfd_elf_link_record_dynamic_symbol (info, h);
|
bfd_elf_link_record_dynamic_symbol (info, h);
|
||||||
}
|
}
|
||||||
return &h->root;
|
return &h->root;
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2018-01-31 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR ld/21964
|
||||||
|
* testsuite/ld-elf/pr21964-4.c: New file.
|
||||||
|
* testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.
|
||||||
|
|
||||||
2018-01-30 Alan Modra <amodra@gmail.com>
|
2018-01-30 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* testsuite/ld-gc/stop.d,
|
* testsuite/ld-gc/stop.d,
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern int __start___verbose[];
|
||||||
|
int bar (void)
|
||||||
|
{
|
||||||
|
static int my_var __attribute__ ((section("__verbose"), used)) = 6;
|
||||||
|
int *ptr;
|
||||||
|
ptr = (int*) dlsym (RTLD_DEFAULT, "__start___verbose");
|
||||||
|
if (ptr != NULL || __start___verbose[0] != 6)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
if (bar () == 0)
|
||||||
|
printf ("PASS\n");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1099,6 +1099,18 @@ if { [istarget *-*-linux*]
|
||||||
"pr22393-2-static" \
|
"pr22393-2-static" \
|
||||||
"pass.out" \
|
"pass.out" \
|
||||||
] \
|
] \
|
||||||
|
[list \
|
||||||
|
"Run pr21964-4" \
|
||||||
|
"" \
|
||||||
|
"" \
|
||||||
|
{pr21964-4.c} \
|
||||||
|
"pr21964-4" \
|
||||||
|
"pass.out" \
|
||||||
|
"" \
|
||||||
|
"" \
|
||||||
|
"" \
|
||||||
|
"-ldl" \
|
||||||
|
] \
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue