Warn when a script redefines a symbol

Note that we don't even warn if scripts adjust a symbol as in
ld-elf/var1 and ld-scripts/pr14962.

include/
	* bfdlink.h (struct bfd_link_info): Add warn_multiple_definition.
ld/
	* ldexp.c (exp_fold_tree_1): Warn on script defining a symbol
	defined in an object file.
	* ldmain.c (multiple_definition): Heed info->warn_multiple_definition.
	* testsuite/ld-scripts/defined5.d: Expect a warning.
This commit is contained in:
Alan Modra
2021-02-20 15:45:44 +10:30
parent 93993f6784
commit 89753bbf81
6 changed files with 32 additions and 11 deletions

View File

@@ -465,12 +465,16 @@ struct bfd_link_info
statics. */
unsigned int task_link: 1;
/* TRUE if ok to have multiple definition. */
/* TRUE if ok to have multiple definitions, without warning. */
unsigned int allow_multiple_definition: 1;
/* TRUE if ok to have prohibit multiple definition of absolute symbols. */
/* TRUE if multiple definition of absolute symbols (eg. from -R) should
be reported. */
unsigned int prohibit_multiple_definition_absolute: 1;
/* TRUE if multiple definitions should only warn. */
unsigned int warn_multiple_definition: 1;
/* TRUE if ok to have version with no definition. */
unsigned int allow_undefined_version: 1;