Renlin Li 93f4de3929 [BFD][PR21703]Override the new defined symbol with the old normal symbol when --allow-multiple-definition is provided.
The behavior of _bfd_elf_merge_symbol and _bfd_generic_link_add_one_symbol is
inconsistent.

In multiple definition case, _bfd_elf_merge_symbol decided to override the old
symbol definition with the new defintion, (size, type, target data)
In _bfd_generic_link_add_one_symbol, it simply return without doing anything
because of allow-multiple-definition is provided.
This leaves the symbol in a wrong state.

Here, following the documentation, I made this patch to force the old definition
override the new definition if the old symbol is not dynamic or weak.
Because, in those two cases, it's expected to do some merge. I have checked
that, those two cases are properly handled.

bfd/
	PR ld/21703
	* elflink.c (_bfd_elf_merge_symbol): Handle multiple definition case.

ld/

	PR ld/21703
	* testsuite/ld-elf/elf.exp: Run new tests.
	* testsuite/ld-elf/pr21703-1.s: New.
	* testsuite/ld-elf/pr21703-2.s: New.
	* testsuite/ld-elf/pr21703-3.s: New.
	* testsuite/ld-elf/pr21703-4.s: New.
	* testsuite/ld-elf/pr21703-r.sd: New.
	* testsuite/ld-elf/pr21703-shared.sd: New.
	* testsuite/ld-elf/pr21703.sd: New.
	* testsuite/ld-elf/pr21703.ver: New.
2017-10-24 13:01:48 +01:00
..
2017-08-31 20:07:13 +09:30
2017-06-08 19:00:36 +02:00
2017-10-05 12:03:47 +10:30
2017-02-17 01:26:12 +00:00
2017-02-17 01:26:12 +00:00
2015-08-12 04:32:43 -07:00
2016-01-01 22:59:17 +10:30
2017-01-02 13:55:05 +10:30
2015-08-12 04:32:43 -07:00
2015-08-12 04:32:43 -07:00
2017-07-18 16:58:14 +01:00
2017-07-03 22:03:48 +09:30
2017-07-18 16:58:14 +01:00
2017-07-03 21:55:57 +09:30
2017-04-13 17:07:24 +09:30
2017-07-18 16:58:14 +01:00
2017-09-25 22:01:47 +09:30
2017-10-09 13:23:00 +10:30
2017-07-18 16:58:14 +01:00
2017-07-19 09:56:55 +02:00
2017-06-27 14:47:02 +05:30
2017-10-14 11:32:52 -07:00
2017-07-18 16:58:14 +01:00
2017-06-01 22:47:32 +09:30
2017-10-14 11:32:52 -07:00
2017-09-02 11:00:02 +09:30
2017-06-23 08:00:46 +02:00
2017-10-14 11:32:52 -07:00
2017-10-14 11:32:52 -07:00
2017-08-29 12:58:51 -07:00
2017-08-29 12:58:51 -07:00
2017-04-13 17:07:24 +09:30
2017-07-18 16:58:14 +01:00
2017-07-18 16:58:14 +01:00
2017-10-24 00:00:31 +00:00
2017-07-04 11:15:33 +02:00
2017-10-05 12:03:47 +10:30
2017-07-18 16:58:14 +01:00

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

BFD is an object file library.  It permits applications to use the
same routines to process object files regardless of their format.

BFD is used by the GNU debugger, assembler, linker, and the binary
utilities.

The documentation on using BFD is scanty and may be occasionally
incorrect.  Pointers to documentation problems, or an entirely
rewritten manual, would be appreciated.

There is some BFD internals documentation in doc/bfdint.texi which may
help programmers who want to modify BFD.

BFD is normally built as part of another package.  See the build
instructions for that package, probably in a README file in the
appropriate directory.

BFD supports the following configure options:

  --target=TARGET
	The default target for which to build the library.  TARGET is
	a configuration target triplet, such as sparc-sun-solaris.
  --enable-targets=TARGET,TARGET,TARGET...
	Additional targets the library should support.  To include
	support for all known targets, use --enable-targets=all.
  --enable-64-bit-bfd
	Include support for 64 bit targets.  This is automatically
	turned on if you explicitly request a 64 bit target, but not
	for --enable-targets=all.  This requires a compiler with a 64
	bit integer type, such as gcc.
  --enable-shared
	Build BFD as a shared library.
  --with-mmap
	Use mmap when accessing files.  This is faster on some hosts,
	but slower on others.  It may not work on all hosts.

Report bugs with BFD to bug-binutils@gnu.org.

Patches are encouraged.  When sending patches, always send the output
of diff -u or diff -c from the original file to the new file.  Do not
send default diff output.  Do not make the diff from the new file to
the original file.  Remember that any patch must not break other
systems.  Remember that BFD must support cross compilation from any
host to any target, so patches which use ``#ifdef HOST'' are not
acceptable.  Please also read the ``Reporting Bugs'' section of the
gcc manual.

Bug reports without patches will be remembered, but they may never get
fixed until somebody volunteers to fix them.

Copyright (C) 2012-2017 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.