public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* multiple definition warnings from script symbols
@ 2021-05-07  6:55 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2021-05-07  6:55 UTC (permalink / raw)
  To: binutils

In commit 89753bbf81 I enabled a warning for scripts redefining
symbols.  The idea was to not warn for symbols defined by shared
libraries (the h->u.def.section->output_section != NULL test), but the
test failed to take into account absolute symbols.  Absolute symbols
defined in shared libraries are currently indistinguishable from
absolute symbols defined in relocatable objects, at least when only
looking at struct bfd_link_hash_entry.  So, don't warn for any
absolute symbols.

	* ldexp.c (update_definedness): Don't return false for absolute
	symbols.
	* ldmain.c (multiple_definition): Print "warning: " in message
	when not a hard error.

diff --git a/ld/ldexp.c b/ld/ldexp.c
index 2efbec658be..02c76f8b33c 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -325,6 +325,7 @@ update_definedness (const char *name, struct bfd_link_hash_entry *h)
       defentry->by_object = 1;
       if (h->type == bfd_link_hash_defined
 	  && h->u.def.section->output_section != NULL
+	  && !bfd_is_abs_section (h->u.def.section)
 	  && !h->linker_def)
 	ret = false;
     }
diff --git a/ld/ldmain.c b/ld/ldmain.c
index be33b6943c6..42660eb9a3c 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -1073,10 +1073,12 @@ multiple_definition (struct bfd_link_info *info,
       nval = oval;
       obfd = NULL;
     }
-  if (!info->warn_multiple_definition)
-    einfo ("%X");
-  einfo (_("%P: %C: multiple definition of `%pT'"),
-	 nbfd, nsec, nval, name);
+  if (info->warn_multiple_definition)
+    einfo (_("%P: %C: warning: multiple definition of `%pT'"),
+	   nbfd, nsec, nval, name);
+  else
+    einfo (_("%X%P: %C: multiple definition of `%pT'"),
+	   nbfd, nsec, nval, name);
   if (obfd != NULL)
     einfo (_("; %D: first defined here"), obfd, osec, oval);
   einfo ("\n");

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-18  6:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07  6:55 multiple definition warnings from script symbols Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).