From 5df1bc570fcc5ef5257b7a044acdaeb6b95b9822 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 20 Jul 2016 15:06:49 +0930 Subject: Fix implib test failures bfd/ * elf.c (_bfd_elf_filter_global_symbols): Skip local symbols. (swap_out_syms): Return an error when not finding ELF output section rather than asserting. * elflink.c (elf_output_implib): Call bfd_set_error on no symbols. ld/ * testsuite/lib/ld-lib.exp (run_ld_link_tests): Add optional parameter to pass list of xfails. * testsuite/ld-elf/elf.exp: Add xfails for implib tests. Tidy implib test formatting. Don't set .data start address. * testsuite/ld-elf/implib.s: Remove first .bss directive and replace second one with equivalent .section directive. * testsuite/ld-elf/empty-implib.out: Add expected final error. * testsuite/ld-elf/implib.rd: Update. --- bfd/ChangeLog | 10 ++++++++++ bfd/elf.c | 10 +++++----- bfd/elflink.c | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ddf29bf..b145feb 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2016-07-21 Nick Clifton + + * elf.c (_bfd_elf_filter_global_symbols): Skip local symbols. + (swap_out_syms): Return an error when not finding ELF output + section rather than asserting. + +2016-07-21 Thomas Preud'homme + + * elflink.c (elf_output_implib): Call bfd_set_error on no symbols. + 2016-07-20 John Baldwin * elf.c (elfcore_grok_freebsd_psinfo): Check for minimum note size diff --git a/bfd/elf.c b/bfd/elf.c index ba1774e..274cd53 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -3893,9 +3893,10 @@ _bfd_elf_filter_global_symbols (bfd *abfd, struct bfd_link_info *info, continue; h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, FALSE); + if (h == NULL) + continue; if (h->type != bfd_link_hash_defined && h->type != bfd_link_hash_defweak) continue; - if (h->linker_def || h->ldscript_def) continue; @@ -7643,7 +7644,9 @@ error_return: section of a symbol to be a section that is actually in the output file. */ sec2 = bfd_get_section_by_name (abfd, sec->name); - if (sec2 == NULL) + if (sec2 != NULL) + shndx = _bfd_elf_section_from_bfd_section (abfd, sec2); + if (shndx == SHN_BAD) { _bfd_error_handler (_("\ Unable to find equivalent output section for symbol '%s' from section '%s'"), @@ -7652,9 +7655,6 @@ Unable to find equivalent output section for symbol '%s' from section '%s'"), bfd_set_error (bfd_error_invalid_operation); goto error_return; } - - shndx = _bfd_elf_section_from_bfd_section (abfd, sec2); - BFD_ASSERT (shndx != SHN_BAD); } } diff --git a/bfd/elflink.c b/bfd/elflink.c index a994b83..5bc5740 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11091,6 +11091,7 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info) symcount = _bfd_elf_filter_global_symbols (abfd, info, sympp, symcount); if (symcount == 0) { + bfd_set_error (bfd_error_no_symbols); (*_bfd_error_handler) (_("%B: no symbol found for import library"), implib_bfd); goto free_sym_buf; -- cgit v1.1