For conveniece, attached are 3 dpatches based on binutils-2.20.1-12 .
#! /bin/sh /usr/share/dpatch/dpatch-run ## 200_elflink_%B_fixes.dpatch by <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Description: Fixes several msgs; needed for later elflink patches ## DP: Upstream status: submitted upstream for binutils-2_20-branch
2010-08-07 Kirill Smelkov <[email protected]> Backport from mainline: 2009-10-12 Roland McGrath <[email protected]> * elflink.c (elf_link_add_object_symbols, _bfd_elf_merge_symbol): Fix %s that should be %B in several message formats. @DPATCH@ diff --git a/bfd/elflink.c b/bfd/elflink.c index c42c6e1..4a348de 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1110,19 +1110,19 @@ _bfd_elf_merge_symbol (bfd *abfd, if (tdef && ntdef) (*_bfd_error_handler) - (_("%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"), + (_("%B: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"), tbfd, tsec, ntbfd, ntsec, h->root.root.string); else if (!tdef && !ntdef) (*_bfd_error_handler) - (_("%s: TLS reference in %B mismatches non-TLS reference in %B"), + (_("%B: TLS reference in %B mismatches non-TLS reference in %B"), tbfd, ntbfd, h->root.root.string); else if (tdef) (*_bfd_error_handler) - (_("%s: TLS definition in %B section %A mismatches non-TLS reference in %B"), + (_("%B: TLS definition in %B section %A mismatches non-TLS reference in %B"), tbfd, tsec, ntbfd, h->root.root.string); else (*_bfd_error_handler) - (_("%s: TLS reference in %B mismatches non-TLS definition in %B section %A"), + (_("%B: TLS reference in %B mismatches non-TLS definition in %B section %A"), tbfd, ntbfd, ntsec, h->root.root.string); bfd_set_error (bfd_error_bad_value); @@ -4437,7 +4437,7 @@ error_free_dyn: if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0) { (*_bfd_error_handler) - (_("%s: invalid DSO for symbol `%s' definition"), + (_("%B: invalid DSO for symbol `%s' definition"), abfd, name); bfd_set_error (bfd_error_bad_value); goto error_free_vers; @@ -12495,7 +12495,7 @@ _bfd_elf_get_dynamic_reloc_section (bfd * abfd, section does not exist it is created and attached to the DYNOBJ bfd and stored in the SRELOC field of SEC's elf_section_data structure. - + ALIGNMENT is the alignment for the newly created section and IS_RELA defines whether the name should be .rela.<SEC's name> or .rel.<SEC's name>. The section name is looked up in the -- 1.7.2.1.44.g721e7
#! /bin/sh /usr/share/dpatch/dpatch-run ## 201_elflink_improve_errors.dpatch by <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Improves error messages regarding -no-add-needed cases; needed for ## DP: later elflink patches ## DP: Upstream status: submitted upstream for binutils-2_20-branch 2010-08-07 Kirill Smelkov <[email protected]> Backport from mainline: 2009-11-05 Nick Clifton <[email protected]> * elflink.c (elf_link_add_object_symbols): Improve error message generated when a symbol is left unresolved because a --no-add-needed command line option has prevented the inclusion of the DSO defining it. @DPATCH@ diff --git a/bfd/elflink.c b/bfd/elflink.c index 4a348de..10eee8c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3866,6 +3866,7 @@ error_free_dyn: bfd_boolean common; unsigned int old_alignment; bfd *old_bfd; + bfd * undef_bfd = NULL; override = FALSE; @@ -4097,6 +4098,20 @@ error_free_dyn: name = newname; } + /* 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 (! 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.u.undef.abfd) + undef_bfd = h->root.u.undef.abfd; + } + if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value, &old_alignment, sym_hash, &skip, &override, @@ -4437,9 +4452,12 @@ error_free_dyn: if ((elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0) { (*_bfd_error_handler) - (_("%B: invalid DSO for symbol `%s' definition"), + (_("%B: undefined reference to symbol '%s'"), + undef_bfd == NULL ? info->output_bfd : undef_bfd, name); + (*_bfd_error_handler) + (_("note: '%s' is defined in DSO %B so try adding it to the linker command line"), abfd, name); - bfd_set_error (bfd_error_bad_value); + bfd_set_error (bfd_error_invalid_operation); goto error_free_vers; } -- 1.7.2.1.44.g721e7
#! /bin/sh /usr/share/dpatch/dpatch-run ## 202_elflink_noaddneeded_vs_weak.dpatch by <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fixes '-no-add-needed breaks linking with weak symbols' ## DP: Upstream status: submitted upstream for binutils-2_20-branch 2010-08-07 Kirill Smelkov <[email protected]> Backport from mainline: 2010-01-21 Nick Clifton <[email protected]> * elflink.c (elf_link_add_object_symbols): Look up name of undefined symbol both before and after versioning has been applied. Do not bother with symbols that are weakly undefined. @DPATCH@ diff --git a/bfd/elflink.c b/bfd/elflink.c index 10eee8c..e058064 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3991,6 +3991,20 @@ error_free_dyn: unsigned int vernum = 0; bfd_boolean skip; + /* 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.u.undef.abfd) + undef_bfd = h->root.u.undef.abfd; + } + if (ever == NULL) { if (info->default_imported_symver) @@ -4098,16 +4112,15 @@ error_free_dyn: name = newname; } - /* 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 (! bfd_is_und_section (sec)) + /* 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.type == bfd_link_hash_undefweak) + && h->root.type == bfd_link_hash_undefined && h->root.u.undef.abfd) undef_bfd = h->root.u.undef.abfd; } @@ -4448,12 +4461,14 @@ 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) (_("%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); -- 1.7.2.1.44.g721e7

