• 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

修訂1134e6ce012575e6d0e99933d0d29cc7978af9af (tree)
時間2016-03-09 22:59:31
作者H.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

Treat common symbol in executable as definition

Common symbol in executable is a definition, which overrides definition
from shared objects. When linker sees a new definition from a shared
object, the new dynamic definition should be overridden by the previous
common symbol in executable.

Backport from master

bfd/

PR ld/19579
* elflink.c (_bfd_elf_merge_symbol): Group common symbol checking
together.

* elflink.c (_bfd_elf_merge_symbol): Treat common symbol in
executable as definition if the new definition comes from a
shared library.

ld/

PR ld/19579
* testsuite/ld-elf/pr19579a.c: New file.
* testsuite/ld-elf/pr19579b.c: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/19579 test.

Change Summary

差異

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,18 @@
1+2016-03-09 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ PR ld/19579
4+ Backport from master
5+ 2016-03-08 H.J. Lu <hongjiu.lu@intel.com>
6+
7+ * elflink.c (_bfd_elf_merge_symbol): Group common symbol checking
8+ together.
9+
10+ 2016-03-04 H.J. Lu <hongjiu.lu@intel.com>
11+
12+ * elflink.c (_bfd_elf_merge_symbol): Treat common symbol in
13+ executable as definition if the new definition comes from a
14+ shared library.
15+
116 2016-03-09 Nick Clifton <nickc@redhat.com>
217 Alan Modra <amodra@gmail.com>
318
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1485,13 +1485,16 @@ _bfd_elf_merge_symbol (bfd *abfd,
14851485 represent variables; this can cause confusion in principle, but
14861486 any such confusion would seem to indicate an erroneous program or
14871487 shared library. We also permit a common symbol in a regular
1488- object to override a weak symbol in a shared object. */
1488+ object to override a weak symbol in a shared object. A common
1489+ symbol in executable also overrides a symbol in a shared object. */
14891490
14901491 if (newdyn
14911492 && newdef
14921493 && (olddef
14931494 || (h->root.type == bfd_link_hash_common
1494- && (newweak || newfunc))))
1495+ && (newweak
1496+ || newfunc
1497+ || (!olddyn && bfd_link_executable (info))))))
14951498 {
14961499 *override = TRUE;
14971500 newdef = FALSE;
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
1+2016-03-09 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ Backport from master
4+ 2016-03-04 H.J. Lu <hongjiu.lu@intel.com>
5+
6+ PR ld/19579
7+ * testsuite/ld-elf/pr19579a.c: New file.
8+ * testsuite/ld-elf/pr19579b.c: Likewise.
9+ * testsuite/ld-elf/shared.exp: Run PR ld/19579 test.
10+
111 2016-03-04 H.J. Lu <hongjiu.lu@intel.com>
212
313 Backport from master
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19579a.c
@@ -0,0 +1,15 @@
1+#include <stdio.h>
2+
3+int foo[1];
4+int bar[2];
5+
6+extern int *foo_p (void);
7+extern int *bar_p (void);
8+
9+int
10+main ()
11+{
12+ if (foo[0] == 0 && foo == foo_p () && bar[0] == 0 && bar == bar_p ())
13+ printf ("PASS\n");
14+ return 0;
15+}
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr19579b.c
@@ -0,0 +1,14 @@
1+int foo[2];
2+int bar[2] = { -1, -1 };
3+
4+int *
5+foo_p (void)
6+{
7+ return foo;
8+}
9+
10+int *
11+bar_p (void)
12+{
13+ return bar;
14+}
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -524,6 +524,21 @@ if { [istarget *-*-linux*]
524524 {} \
525525 "libpr2404b.a" \
526526 ] \
527+ [list \
528+ "Build pr19579a.o" \
529+ "" "-fPIE" \
530+ {pr19579a.c} \
531+ {} \
532+ "libpr19579a.a" \
533+ ] \
534+ [list \
535+ "Build libpr19579.so" \
536+ "-shared" \
537+ "-fPIC" \
538+ {pr19579b.c} \
539+ {} \
540+ "libpr19579.so" \
541+ ] \
527542 ]
528543 run_ld_link_exec_tests [] [list \
529544 [list \
@@ -580,5 +595,14 @@ if { [istarget *-*-linux*]
580595 "pass.out" \
581596 "-O2 -fPIC -I../bfd" \
582597 ] \
598+ [list \
599+ "Run pr19579" \
600+ "-pie -z text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
601+ "" \
602+ {dummy.c} \
603+ "pr19579" \
604+ "pass.out" \
605+ "-fPIE" \
606+ ] \
583607 ]
584608 }