Fix --no-copy-dt-needed so that it does not complain about weak references.

Fix --no-copy-dt-needed so that it reports the correct input file which
    needs a DSO.
This commit is contained in:
Nicholas Clifton 2010-01-20 09:48:52 +00:00
parent cff4ada549
commit 8d40e3a0e8
2 changed files with 73 additions and 51 deletions

View File

@ -1,6 +1,6 @@
diff -rup ../binutils-2.20.51.0.2.original/bfd/elflink.c ./bfd/elflink.c
--- ../binutils-2.20.51.0.2.original/bfd/elflink.c 2009-11-05 17:42:05.000000000 +0000
+++ ./bfd/elflink.c 2009-11-05 17:48:23.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/bfd/elflink.c ./bfd/elflink.c
--- ../binutils-2.20.51.0.2/bfd/elflink.c 2010-01-20 08:27:19.000000000 +0000
+++ ./bfd/elflink.c 2010-01-20 08:35:12.000000000 +0000
@@ -3918,6 +3918,7 @@ error_free_dyn:
bfd_boolean common;
unsigned int old_alignment;
@ -9,20 +9,40 @@ diff -rup ../binutils-2.20.51.0.2.original/bfd/elflink.c ./bfd/elflink.c
override = FALSE;
@@ -4149,6 +4150,20 @@ error_free_dyn:
name = newname;
}
@@ -4042,6 +4043,20 @@ error_free_dyn:
unsigned int vernum = 0;
bfd_boolean skip;
+ /* If this is a definition of a previously undefined symbol
+ make a note of the bfd that contained the reference in
+ case we need to refer to it later on in error messages. */
+ /* If this is a definition of a symbol which was previously
+ referenced in a non-weak manner then make a note of the bfd
+ that contained the reference. This is used if we need to
+ refer to the source of the reference later on. */
+ if (! bfd_is_und_section (sec))
+ {
+ h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
+
+ if (h != NULL
+ && (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && h->root.type == bfd_link_hash_undefined
+ && h->root.u.undef.abfd)
+ undef_bfd = h->root.u.undef.abfd;
+ }
+
if (ever == NULL)
{
if (info->default_imported_symver)
@@ -4149,6 +4164,19 @@ error_free_dyn:
name = newname;
}
+ /* If necessary, make a second attempt to locate the bfd
+ containing an unresolved, non-weak reference to the
+ current symbol. */
+ if (! bfd_is_und_section (sec) && undef_bfd == NULL)
+ {
+ h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
+
+ if (h != NULL
+ && h->root.type == bfd_link_hash_undefined
+ && h->root.u.undef.abfd)
+ undef_bfd = h->root.u.undef.abfd;
+ }
@ -30,13 +50,21 @@ diff -rup ../binutils-2.20.51.0.2.original/bfd/elflink.c ./bfd/elflink.c
if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec,
&value, &old_alignment,
sym_hash, &skip, &override,
@@ -4506,9 +4521,12 @@ error_free_dyn:
if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
@@ -4502,13 +4530,18 @@ error_free_dyn:
/* A symbol from a library loaded via DT_NEEDED of some
other library is referenced by a regular object.
Add a DT_NEEDED entry for it. Issue an error if
- --no-add-needed is used. */
- if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
+ --no-add-needed is used and the reference was not
+ a weak one. */
+ if (undef_bfd != NULL
+ && (elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
{
(*_bfd_error_handler)
- (_("%s: invalid DSO for symbol `%s' definition"),
+ (_("%B: undefined reference to symbol '%s'"),
+ undef_bfd == NULL ? info->output_bfd : undef_bfd, name);
+ undef_bfd, name);
+ (*_bfd_error_handler)
+ (_("note: '%s' is defined in DSO %B so try adding it to the linker command line"),
abfd, name);
@ -45,18 +73,9 @@ diff -rup ../binutils-2.20.51.0.2.original/bfd/elflink.c ./bfd/elflink.c
goto error_free_vers;
}
diff -rup ../binutils-2.20.51.0.2.original/gas/testsuite/gas/elf/elf.exp ./gas/testsuite/gas/elf/elf.exp
--- ../binutils-2.20.51.0.2.original/gas/testsuite/gas/elf/elf.exp 2009-11-05 17:42:03.000000000 +0000
+++ ./gas/testsuite/gas/elf/elf.exp 2009-11-05 18:11:55.000000000 +0000
@@ -151,5 +151,4 @@ if { ([istarget "*-*-*elf*"]
run_dump_test "section7"
run_dump_test "dwarf2-1"
run_dump_test "dwarf2-2"
- run_dump_test "dwarf2-3"
}
diff -rup ../binutils-2.20.51.0.2.original/ld/emultempl/elf32.em ./ld/emultempl/elf32.em
--- ../binutils-2.20.51.0.2.original/ld/emultempl/elf32.em 2009-11-05 17:41:58.000000000 +0000
+++ ./ld/emultempl/elf32.em 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/emultempl/elf32.em ./ld/emultempl/elf32.em
--- ../binutils-2.20.51.0.2/ld/emultempl/elf32.em 2009-10-09 23:26:22.000000000 +0100
+++ ./ld/emultempl/elf32.em 2010-01-13 16:01:13.000000000 +0000
@@ -110,7 +110,7 @@ fi
if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
@ -91,9 +110,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/emultempl/elf32.em ./ld/emultempl/
|| (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
return FALSE;
diff -rup ../binutils-2.20.51.0.2.original/ld/ldgram.y ./ld/ldgram.y
--- ../binutils-2.20.51.0.2.original/ld/ldgram.y 2009-11-05 17:42:00.000000000 +0000
+++ ./ld/ldgram.y 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ldgram.y ./ld/ldgram.y
--- ../binutils-2.20.51.0.2/ld/ldgram.y 2009-09-08 18:11:39.000000000 +0100
+++ ./ld/ldgram.y 2010-01-13 16:01:16.000000000 +0000
@@ -378,17 +378,17 @@ input_list:
{ lang_add_input_file($2,lang_input_file_is_l_enum,
(char *)NULL); }
@ -118,9 +137,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ldgram.y ./ld/ldgram.y
;
sections:
diff -rup ../binutils-2.20.51.0.2.original/ld/ldlang.c ./ld/ldlang.c
--- ../binutils-2.20.51.0.2.original/ld/ldlang.c 2009-11-05 17:42:00.000000000 +0000
+++ ./ld/ldlang.c 2009-11-05 18:01:29.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ldlang.c ./ld/ldlang.c
--- ../binutils-2.20.51.0.2/ld/ldlang.c 2009-10-09 23:25:30.000000000 +0100
+++ ./ld/ldlang.c 2010-01-13 16:01:16.000000000 +0000
@@ -1056,8 +1056,8 @@ new_afile (const char *name,
p->next_real_file = NULL;
p->next = NULL;
@ -168,9 +187,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ldlang.c ./ld/ldlang.c
pop_stat_ptr ();
return TRUE;
diff -rup ../binutils-2.20.51.0.2.original/ld/ldlang.h ./ld/ldlang.h
--- ../binutils-2.20.51.0.2.original/ld/ldlang.h 2009-11-05 17:41:58.000000000 +0000
+++ ./ld/ldlang.h 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ldlang.h ./ld/ldlang.h
--- ../binutils-2.20.51.0.2/ld/ldlang.h 2009-10-09 23:25:30.000000000 +0100
+++ ./ld/ldlang.h 2010-01-13 16:01:13.000000000 +0000
@@ -270,11 +270,11 @@ typedef struct lang_input_statement_stru
/* Whether DT_NEEDED tags should be added for dynamic libraries in
@ -185,9 +204,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ldlang.h ./ld/ldlang.h
/* Whether to include the entire contents of an archive. */
unsigned int whole_archive : 1;
diff -rup ../binutils-2.20.51.0.2.original/ld/ldmain.c ./ld/ldmain.c
--- ../binutils-2.20.51.0.2.original/ld/ldmain.c 2009-11-05 17:42:00.000000000 +0000
+++ ./ld/ldmain.c 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ldmain.c ./ld/ldmain.c
--- ../binutils-2.20.51.0.2/ld/ldmain.c 2010-01-20 08:27:18.000000000 +0000
+++ ./ld/ldmain.c 2010-01-13 16:01:16.000000000 +0000
@@ -93,13 +93,14 @@ bfd_boolean version_printed;
/* Nonzero means link in every member of an archive. */
bfd_boolean whole_archive;
@ -210,9 +229,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ldmain.c ./ld/ldmain.c
/* TRUE if we should demangle symbol names. */
bfd_boolean demangling;
diff -rup ../binutils-2.20.51.0.2.original/ld/ldmain.h ./ld/ldmain.h
--- ../binutils-2.20.51.0.2.original/ld/ldmain.h 2009-11-05 17:41:58.000000000 +0000
+++ ./ld/ldmain.h 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ldmain.h ./ld/ldmain.h
--- ../binutils-2.20.51.0.2/ld/ldmain.h 2009-10-09 23:26:22.000000000 +0100
+++ ./ld/ldmain.h 2010-01-13 16:01:12.000000000 +0000
@@ -1,6 +1,6 @@
/* ldmain.h -
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2002, 2003, 2004,
@ -232,9 +251,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ldmain.h ./ld/ldmain.h
extern bfd_boolean demangling;
extern enum report_method how_to_report_unresolved_symbols;
extern int g_switch_value;
diff -rup ../binutils-2.20.51.0.2.original/ld/ld.texinfo ./ld/ld.texinfo
--- ../binutils-2.20.51.0.2.original/ld/ld.texinfo 2009-11-05 17:41:58.000000000 +0000
+++ ./ld/ld.texinfo 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/ld.texinfo ./ld/ld.texinfo
--- ../binutils-2.20.51.0.2/ld/ld.texinfo 2010-01-20 08:27:18.000000000 +0000
+++ ./ld/ld.texinfo 2010-01-13 16:01:12.000000000 +0000
@@ -1132,27 +1132,24 @@ restore the old behaviour.
@item --as-needed
@itemx --no-as-needed
@ -303,9 +322,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/ld.texinfo ./ld/ld.texinfo
@cindex cross reference table
@kindex --cref
@item --cref
diff -rup ../binutils-2.20.51.0.2.original/ld/lexsup.c ./ld/lexsup.c
--- ../binutils-2.20.51.0.2.original/ld/lexsup.c 2009-11-05 17:42:00.000000000 +0000
+++ ./ld/lexsup.c 2009-11-05 17:45:22.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/lexsup.c ./ld/lexsup.c
--- ../binutils-2.20.51.0.2/ld/lexsup.c 2009-10-09 23:26:22.000000000 +0100
+++ ./ld/lexsup.c 2010-01-13 16:01:15.000000000 +0000
@@ -125,10 +125,10 @@ enum option_values
OPTION_SPLIT_BY_RELOC,
OPTION_SPLIT_BY_FILE ,
@ -397,9 +416,9 @@ diff -rup ../binutils-2.20.51.0.2.original/ld/lexsup.c ./ld/lexsup.c
break;
case OPTION_WRAP:
add_wrap (optarg);
diff -rup ../binutils-2.20.51.0.2.original/ld/NEWS ./ld/NEWS
--- ../binutils-2.20.51.0.2.original/ld/NEWS 2009-11-05 17:42:00.000000000 +0000
+++ ./ld/NEWS 2009-11-05 17:45:59.000000000 +0000
diff -rup ../binutils-2.20.51.0.2/ld/NEWS ./ld/NEWS
--- ../binutils-2.20.51.0.2/ld/NEWS 2010-01-20 08:27:18.000000000 +0000
+++ ./ld/NEWS 2010-01-13 16:01:16.000000000 +0000
@@ -1,5 +1,8 @@
-*- text -*-

View File

@ -17,7 +17,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.20.51.0.2
Release: 11%{?dist}
Release: 12%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -427,6 +427,9 @@ exit 0
%endif # %{isnative}
%changelog
* Wed Jan 20 2010 Nick Clifton <nickc@redhat.com> - 2.20.51.0.2-12
- Fix --no-copy-dt-needed so that it will not complain about weak references.
* Fri Dec 18 2009 Nick Clifton <nickc@redhat.com> - 2.20.51.0.2-11
- Add missing part of PR 11088 patch.