This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] [BFD] Fix override of COMMON symbols for a.out
- From: gnikl at users dot sourceforge dot net
- To: binutils at sourceware dot org
- Cc: Nick Clifton <nickc at redhat dot com>
- Date: Thu, 11 Jan 2018 19:54:54 +0100
- Subject: [PATCH] [BFD] Fix override of COMMON symbols for a.out
- Authentication-results: sourceware.org; auth=none
Hello,
The included patch is an attempt to fix a by now ancient bug in the
a.out
backend.
BFD initially merged a COMMON symbol with another symbol found in a
linker archive. Later a modification was suggested to make it possible
for a linker emulation to alter that behaviour. The patch for this
change was posted here:
https://sourceware.org/ml/binutils/2002-07/msg00717.html
However, the code was modified before the commit:
https://sourceware.org/git/?p=binutils.git;a=commit;h=d8f30db44739af73d229f540fd9030603350bc35
A default case was added, which completely changed the behaviour. The
problem is, that the default value of link_info.common_skip_ar_symbols
(skip_none) is *not* part of the switch in aout_link_check_ar_symbols.
Without the default case no switch case would trigger and the existing
behaviour would have been kept. Now with the default case attached to
"bfd_link_common_skip_all" a library symbol will never override a
COMMON symbol... I cannot say whether the historical behaviour should
be reestablished as done in the suggested patch. If another change in
behaviour is not desired than the posted patch should be committed with
an addition: change the global default in ld/ldmain.c to "skip_all".
This would keep the current behaviour while allowing the historical
behaviour.
Regards
Gunther Nikl
---
2018-01-12 Gunther Nikl <gnikl@users.sourceforge.net>
* bfd/aoutx.h (aout_link_check_ar_symbols): Add
bfd_link_common_skip_none and make it the switch default.
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -3366,13 +3366,15 @@ aout_link_check_ar_symbols (bfd *abfd,
switch (info->common_skip_ar_symbols)
{
+ default:
+ case bfd_link_common_skip_none:
+ break;
case bfd_link_common_skip_text:
skip = (type == (N_TEXT | N_EXT));
break;
case bfd_link_common_skip_data:
skip = (type == (N_DATA | N_EXT));
break;
- default:
case bfd_link_common_skip_all:
skip = 1;
break;