summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-04-15 14:25:08 +0100
committerNick Clifton <nickc@redhat.com>2020-04-15 14:25:08 +0100
commit95a515681272fa3a79624279c1579cce14ad61c0 (patch)
tree21c4c3be88223c9b38116c46614fc87ac9e7f3d1 /bfd
parentb1bc1394df596eaaecca0c2ae89eb4fb2c204927 (diff)
downloadbinutils-gdb-95a515681272fa3a79624279c1579cce14ad61c0.tar.gz
Unify the behaviour of ld.bfd and ld.gold with respect to warning about unresolved symbol references. (PR 24613)
PR binutils/24613 include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and RM_GENERATE_ERROR. Add RM_DIAGNOSE. (struct bfd_link_info): Add warn_unresolved_syms. ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change RM_GENERATE_ERROR to RM_DIAGNOSE. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise. bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR to RM_DIAGNOSE plus a check of warn_unresolved_syms. * coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise. * elf-bfd.h (_bfd_elf_large_com_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-hppa.c (elf64_hppa_relocate_section): Likewise. * elflink.c (elf_link_output_extsym): Likewise. * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog16
-rw-r--r--bfd/coff-rs6000.c3
-rw-r--r--bfd/coff64-rs6000.c5
-rw-r--r--bfd/elf-bfd.h5
-rw-r--r--bfd/elf32-m32r.c12
-rw-r--r--bfd/elf32-score.c13
-rw-r--r--bfd/elf32-score7.c11
-rw-r--r--bfd/elf32-sh.c13
-rw-r--r--bfd/elf32-spu.c15
-rw-r--r--bfd/elf64-hppa.c17
-rw-r--r--bfd/elflink.c12
-rw-r--r--bfd/elfxx-mips.c9
12 files changed, 79 insertions, 52 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e837fdc1334..2cf36f4c3e0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,19 @@
+2020-04-15 Fangrui Song <maskray@google.com>
+
+ PR binutils/24613
+ * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR
+ to RM_DIAGNOSE plus a check of warn_unresolved_syms.
+ * coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise.
+ * elf-bfd.h (_bfd_elf_large_com_section): Likewise.
+ * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+ * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
+ * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
+ * elf32-sh.c (sh_elf_relocate_section): Likewise.
+ * elf32-spu.c (spu_elf_relocate_section): Likewise.
+ * elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
+ * elflink.c (elf_link_output_extsym): Likewise.
+ * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
+
2020-04-15 Alan Modra <amodra@gmail.com>
PR 25823
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index bf87596a4fe..51fab9f0536 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -3389,7 +3389,8 @@ xcoff_ppc_relocate_section (bfd *output_bfd,
(info, h->root.root.string,
input_bfd, input_section,
rel->r_vaddr - input_section->vma,
- info->unresolved_syms_in_objects == RM_GENERATE_ERROR);
+ info->unresolved_syms_in_objects == RM_DIAGNOSE &&
+ !info->warn_unresolved_syms);
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index d34e25903ce..7185232ce14 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -1249,10 +1249,11 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
{
if (info->unresolved_syms_in_objects != RM_IGNORE
&& (h->flags & XCOFF_WAS_UNDEFINED) != 0)
- (*info->callbacks->undefined_symbol)
+ info->callbacks->undefined_symbol
(info, h->root.root.string, input_bfd, input_section,
rel->r_vaddr - input_section->vma,
- info->unresolved_syms_in_objects == RM_GENERATE_ERROR);
+ info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms);
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 03e2b6fe85a..b08502cd1c4 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2930,8 +2930,9 @@ extern asection _bfd_elf_large_com_section;
else if (!bfd_link_relocatable (info)) \
{ \
bfd_boolean err; \
- err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR \
- || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT); \
+ err = (info->unresolved_syms_in_objects == RM_DIAGNOSE && \
+ !info->warn_unresolved_syms) \
+ || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT; \
(*info->callbacks->undefined_symbol) (info, \
h->root.root.string, \
input_bfd, \
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 2a4b0b2ebea..598fbe5633b 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -2551,12 +2551,12 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else if (!bfd_link_relocatable (info))
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (h->other)));
- }
+ info->callbacks->undefined_symbol
+ (info, h->root.root.string, input_bfd, input_section, offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (h->other));
+ }
if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 8c2e3042ae8..c5e6346e93f 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -2669,13 +2669,14 @@ s3_bfd_score_elf_relocate_section (bfd *output_bfd,
}
else if (!bfd_link_relocatable (info))
{
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ info->callbacks->undefined_symbol
+ (info, h->root.root.root.string, input_bfd, input_section,
+ rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
|| ELF_ST_VISIBILITY (h->root.other));
- relocation = 0;
- }
+ relocation = 0;
+ }
}
if (sec != NULL && discarded_section (sec))
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 752796c45be..0f647feaeb8 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -2443,12 +2443,13 @@ s7_bfd_score_elf_relocate_section (bfd *output_bfd,
}
else if (!bfd_link_relocatable (info))
{
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ info->callbacks->undefined_symbol
+ (info, h->root.root.root.string, input_bfd, input_section,
+ rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
|| ELF_ST_VISIBILITY (h->root.other));
- relocation = 0;
+ relocation = 0;
}
}
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 9a00bde1d99..db07f8f889d 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -3815,12 +3815,13 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else if (!bfd_link_relocatable (info))
- (*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (h->other)));
- }
+ info->callbacks->undefined_symbol
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (h->other));
+ }
if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index 711537d3de6..983989081ae 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -4927,13 +4927,14 @@ spu_elf_relocate_section (bfd *output_bfd,
&& !(r_type == R_SPU_PPU32 || r_type == R_SPU_PPU64))
{
bfd_boolean err;
- err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT);
- (*info->callbacks->undefined_symbol) (info,
- h->root.root.string,
- input_bfd,
- input_section,
- rel->r_offset, err);
+
+ err = (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT;
+
+ info->callbacks->undefined_symbol
+ (info, h->root.root.string, input_bfd,
+ input_section, rel->r_offset, err);
}
sym_name = h->root.root.string;
}
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index a2602daf2b1..ae50b2cd478 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -3882,13 +3882,14 @@ elf64_hppa_relocate_section (bfd *output_bfd,
else if (!bfd_link_relocatable (info))
{
bfd_boolean err;
- err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT);
- (*info->callbacks->undefined_symbol) (info,
- eh->root.root.string,
- input_bfd,
- input_section,
- rel->r_offset, err);
+
+ err = (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT;
+
+ info->callbacks->undefined_symbol
+ (info, eh->root.root.string, input_bfd,
+ input_section, rel->r_offset, err);
}
if (!bfd_link_relocatable (info)
@@ -3900,7 +3901,7 @@ elf64_hppa_relocate_section (bfd *output_bfd,
if (info->unresolved_syms_in_objects == RM_IGNORE
&& ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT
&& eh->type == STT_PARISC_MILLI)
- (*info->callbacks->undefined_symbol)
+ info->callbacks->undefined_symbol
(info, eh_name (eh), input_bfd,
input_section, rel->r_offset, FALSE);
}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7c0849423a3..eb6b3eeca50 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -9886,11 +9886,13 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
&& (!h->ref_regular || flinfo->info->gc_sections)
&& !elf_link_check_versioned_symbol (flinfo->info, bed, h)
&& flinfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
- (*flinfo->info->callbacks->undefined_symbol)
- (flinfo->info, h->root.root.string,
- h->ref_regular ? NULL : h->root.u.undef.abfd,
- NULL, 0,
- flinfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR);
+ {
+ flinfo->info->callbacks->undefined_symbol
+ (flinfo->info, h->root.root.string,
+ h->ref_regular ? NULL : h->root.u.undef.abfd, NULL, 0,
+ flinfo->info->unresolved_syms_in_shared_libs == RM_DIAGNOSE
+ && !flinfo->info->warn_unresolved_syms);
+ }
/* Strip a global symbol defined in a discarded section. */
if (h->indx == -3)
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 4671b504497..ae8478270ef 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -5649,11 +5649,12 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
}
else
{
- bfd_boolean reject_undefined
- = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
- || ELF_ST_VISIBILITY (h->root.other) != STV_DEFAULT);
+ bfd_boolean reject_undefined
+ = (info->unresolved_syms_in_objects == RM_DIAGNOSE
+ && !info->warn_unresolved_syms)
+ || ELF_ST_VISIBILITY (h->root.other) != STV_DEFAULT;
- (*info->callbacks->undefined_symbol)
+ info->callbacks->undefined_symbol
(info, h->root.root.root.string, input_bfd,
input_section, relocation->r_offset, reject_undefined);