aboutsummaryrefslogtreecommitdiff
path: root/ld/ldmain.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-02-20 15:45:44 +1030
committerAlan Modra <amodra@gmail.com>2021-02-21 14:28:16 +1030
commit89753bbf8102edc2aa4262a4d43f1a71a10e34f3 (patch)
tree3afa35082bf7898409aa8e8ff507e8431b32c99d /ld/ldmain.c
parent93993f67849234cff651542c3d4d9f0f3d2fa651 (diff)
downloadgdb-89753bbf8102edc2aa4262a4d43f1a71a10e34f3.zip
gdb-89753bbf8102edc2aa4262a4d43f1a71a10e34f3.tar.gz
gdb-89753bbf8102edc2aa4262a4d43f1a71a10e34f3.tar.bz2
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.
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r--ld/ldmain.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 863df02..5c88ee7 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -1074,7 +1074,9 @@ multiple_definition (struct bfd_link_info *info,
nval = oval;
obfd = NULL;
}
- einfo (_("%X%P: %C: multiple definition of `%pT'"),
+ if (!info->warn_multiple_definition)
+ einfo ("%X");
+ einfo (_("%P: %C: multiple definition of `%pT'"),
nbfd, nsec, nval, name);
if (obfd != NULL)
einfo (_("; %D: first defined here"), obfd, osec, oval);