+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
(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)
{
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)
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, \
&& 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,
}
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))
}
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;
}
}
&& 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,
&& !(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;
}
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)
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);
}
&& (!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)
}
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);
+2020-04-10 Fangrui Song <maskray@google.com>
+
+ PR binutils/24613
+ * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and
+ RM_GENERATE_ERROR. Add RM_DIAGNOSE.
+ (struct bfd_link_info): Add warn_unresolved_syms.
+
2020-04-14 Stephen Casner <casner@acm.org>
PR ld/25677
allowed to set the value. */
RM_NOT_YET_SET = 0,
RM_IGNORE,
- RM_GENERATE_WARNING,
- RM_GENERATE_ERROR
+ RM_DIAGNOSE,
};
typedef enum {with_flags, without_flags} flag_type;
ENUM_BITFIELD (bfd_link_elf_stt_common) elf_stt_common : 2;
/* Criteria for skipping symbols when determining
- whether to include an object from an archive. */
+ whether to include an object from an archive. */
ENUM_BITFIELD (bfd_link_common_skip_ar_symbols) common_skip_ar_symbols : 2;
/* What to do with unresolved symbols in an object file.
The same defaults apply. */
ENUM_BITFIELD (report_method) unresolved_syms_in_shared_libs : 2;
+ /* TRUE if unresolved symbols are to be warned, rather than errored. */
+ unsigned int warn_unresolved_syms: 1;
+
/* TRUE if shared objects should be linked directly, not shared. */
unsigned int static_link: 1;
+2020-04-15 Fangrui Song <maskray@google.com>
+
+ PR binutils/24613
+ * 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.
+
2020-04-14 Stephen Casner <casner@acm.org>
PR ld/25677
break;
case OPTION_ERNOTOK:
- link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
- link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
break;
case OPTION_EROK:
case OPTION_GROUP:
link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
/* Groups must be self-contained. */
- link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
- link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
break;
case OPTION_EXCLUDE_LIBS:
fragment <<EOF
case 'z':
if (strcmp (optarg, "defs") == 0)
- link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
else if (strcmp (optarg, "undefs") == 0)
link_info.unresolved_syms_in_objects = RM_IGNORE;
else if (strcmp (optarg, "muldefs") == 0)
struct option *longopts;
struct option *really_longopts;
int last_optind;
- enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
enum symbolic_enum
{
symbolic_unset = 0,
link_info.keep_memory = FALSE;
break;
case OPTION_NO_UNDEFINED:
- link_info.unresolved_syms_in_objects
- = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
break;
case OPTION_ALLOW_SHLIB_UNDEFINED:
link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
break;
case OPTION_NO_ALLOW_SHLIB_UNDEFINED:
- link_info.unresolved_syms_in_shared_libs
- = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
break;
case OPTION_UNRESOLVED_SYMBOLS:
if (strcmp (optarg, "ignore-all") == 0)
}
else if (strcmp (optarg, "report-all") == 0)
{
- link_info.unresolved_syms_in_objects
- = how_to_report_unresolved_symbols;
- link_info.unresolved_syms_in_shared_libs
- = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
}
else if (strcmp (optarg, "ignore-in-object-files") == 0)
{
link_info.unresolved_syms_in_objects = RM_IGNORE;
- link_info.unresolved_syms_in_shared_libs
- = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
}
else if (strcmp (optarg, "ignore-in-shared-libs") == 0)
{
- link_info.unresolved_syms_in_objects
- = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
}
else
einfo (_("%F%P: bad --unresolved-symbols option: %s\n"), optarg);
break;
case OPTION_WARN_UNRESOLVED_SYMBOLS:
- how_to_report_unresolved_symbols = RM_GENERATE_WARNING;
- if (link_info.unresolved_syms_in_objects == RM_GENERATE_ERROR)
- link_info.unresolved_syms_in_objects = RM_GENERATE_WARNING;
- if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
- link_info.unresolved_syms_in_shared_libs = RM_GENERATE_WARNING;
+ link_info.warn_unresolved_syms = TRUE;
break;
-
case OPTION_ERROR_UNRESOLVED_SYMBOLS:
- how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
- if (link_info.unresolved_syms_in_objects == RM_GENERATE_WARNING)
- link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
- if (link_info.unresolved_syms_in_shared_libs == RM_GENERATE_WARNING)
- link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR;
+ link_info.warn_unresolved_syms = FALSE;
break;
case OPTION_ALLOW_MULTIPLE_DEFINITION:
link_info.allow_multiple_definition = TRUE;
if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
/* FIXME: Should we allow emulations a chance to set this ? */
- link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_objects = RM_DIAGNOSE;
if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
/* FIXME: Should we allow emulations a chance to set this ? */
- link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
+ link_info.unresolved_syms_in_shared_libs = RM_DIAGNOSE;
if (bfd_link_relocatable (&link_info)
&& command_line.check_section_addresses < 0)