• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂823143c6ca8ef4267e67ba03771991e08d09fabd (tree)
時間2018-01-31 22:10:53
作者H.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

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.

Change Summary

差異

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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+
17 2018-01-30 Alan Modra <amodra@gmail.com>
28
39 PR 22758
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -14338,7 +14338,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
1433814338 if (h != NULL
1433914339 && (h->root.type == bfd_link_hash_undefined
1434014340 || 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)))
1434214342 {
1434314343 h->root.type = bfd_link_hash_defined;
1434414344 h->root.u.def.section = sec;
@@ -14358,7 +14358,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
1435814358 {
1435914359 if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1436014360 h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
14361- if (h->ref_dynamic || h->def_dynamic)
14361+ if (h->ref_dynamic)
1436214362 bfd_elf_link_record_dynamic_symbol (info, h);
1436314363 }
1436414364 return &h->root;
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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+
17 2018-01-30 Alan Modra <amodra@gmail.com>
28
39 * testsuite/ld-gc/stop.d,
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21964-4.c
@@ -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+}
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -1099,6 +1099,18 @@ if { [istarget *-*-linux*]
10991099 "pr22393-2-static" \
11001100 "pass.out" \
11011101 ] \
1102+ [list \
1103+ "Run pr21964-4" \
1104+ "" \
1105+ "" \
1106+ {pr21964-4.c} \
1107+ "pr21964-4" \
1108+ "pass.out" \
1109+ "" \
1110+ "" \
1111+ "" \
1112+ "-ldl" \
1113+ ] \
11021114 ]
11031115 }
11041116