GNU Binutils with patches for OS216
修訂 | 823143c6ca8ef4267e67ba03771991e08d09fabd (tree) |
---|---|
時間 | 2018-01-31 22:10:53 |
作者 | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
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.
@@ -1,3 +1,9 @@ | ||
1 | +2018-01-31 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + PR ld/21964 | |
4 | + * elflink.c (bfd_elf_define_start_stop): Check if __start and | |
5 | + __stop symbols are referenced by shared objects. | |
6 | + | |
1 | 7 | 2018-01-30 Alan Modra <amodra@gmail.com> |
2 | 8 | |
3 | 9 | PR 22758 |
@@ -14338,7 +14338,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info, | ||
14338 | 14338 | if (h != NULL |
14339 | 14339 | && (h->root.type == bfd_link_hash_undefined |
14340 | 14340 | || h->root.type == bfd_link_hash_undefweak |
14341 | - || ((h->ref_regular || h->def_dynamic) && !h->def_regular))) | |
14341 | + || ((h->ref_regular || h->ref_dynamic) && !h->def_regular))) | |
14342 | 14342 | { |
14343 | 14343 | h->root.type = bfd_link_hash_defined; |
14344 | 14344 | h->root.u.def.section = sec; |
@@ -14358,7 +14358,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info, | ||
14358 | 14358 | { |
14359 | 14359 | if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) |
14360 | 14360 | h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED; |
14361 | - if (h->ref_dynamic || h->def_dynamic) | |
14361 | + if (h->ref_dynamic) | |
14362 | 14362 | bfd_elf_link_record_dynamic_symbol (info, h); |
14363 | 14363 | } |
14364 | 14364 | return &h->root; |
@@ -1,3 +1,9 @@ | ||
1 | +2018-01-31 H.J. Lu <hongjiu.lu@intel.com> | |
2 | + | |
3 | + PR ld/21964 | |
4 | + * testsuite/ld-elf/pr21964-4.c: New file. | |
5 | + * testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux. | |
6 | + | |
1 | 7 | 2018-01-30 Alan Modra <amodra@gmail.com> |
2 | 8 | |
3 | 9 | * testsuite/ld-gc/stop.d, |
@@ -0,0 +1,22 @@ | ||
1 | +#define _GNU_SOURCE | |
2 | +#include <dlfcn.h> | |
3 | +#include <stdio.h> | |
4 | + | |
5 | +extern int __start___verbose[]; | |
6 | +int bar (void) | |
7 | +{ | |
8 | + static int my_var __attribute__ ((section("__verbose"), used)) = 6; | |
9 | + int *ptr; | |
10 | + ptr = (int*) dlsym (RTLD_DEFAULT, "__start___verbose"); | |
11 | + if (ptr != NULL || __start___verbose[0] != 6) | |
12 | + return -1; | |
13 | + return 0; | |
14 | +} | |
15 | + | |
16 | +int | |
17 | +main () | |
18 | +{ | |
19 | + if (bar () == 0) | |
20 | + printf ("PASS\n"); | |
21 | + return 0; | |
22 | +} |
@@ -1099,6 +1099,18 @@ if { [istarget *-*-linux*] | ||
1099 | 1099 | "pr22393-2-static" \ |
1100 | 1100 | "pass.out" \ |
1101 | 1101 | ] \ |
1102 | + [list \ | |
1103 | + "Run pr21964-4" \ | |
1104 | + "" \ | |
1105 | + "" \ | |
1106 | + {pr21964-4.c} \ | |
1107 | + "pr21964-4" \ | |
1108 | + "pass.out" \ | |
1109 | + "" \ | |
1110 | + "" \ | |
1111 | + "" \ | |
1112 | + "-ldl" \ | |
1113 | + ] \ | |
1102 | 1114 | ] |
1103 | 1115 | } |
1104 | 1116 |