From 1c320501655ec8d5077d0a3231652c7d661249bc Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 21 Nov 2023 09:26:19 +0000 Subject: Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM PR 31067 * linker.c (_bfd_generic_link_add_one_symbol): When issuing a warning message, also display a message about the warning not being affected by garbage colleciton. * ld.texi (Special Sections): New entry in the linker manual. Describes how the .gnu.warning and .gnu.warning.SYM sections behave. --- bfd/ChangeLog | 7 +++++++ bfd/linker.c | 8 ++++++++ 2 files changed, 15 insertions(+) (limited to 'bfd') diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1430698..e9f571a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2023-11-21 Nick Clifton + + PR 31067 + linker.c (_bfd_generic_link_add_one_symbol): When issuing a + warning message, also display a message about the warning not + being affected by garbage colleciton. + 2023-11-15 Arsen Arsenović * aclocal.m4: Regenerate. diff --git a/bfd/linker.c b/bfd/linker.c index 28fffc3..90dc581 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1784,6 +1784,14 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, { (*info->callbacks->warning) (info, string, h->root.string, hash_entry_bfd (h), NULL, 0); + /* PR 31067: If garbage collection is enabled then the + referenced symbol may actually be discarded later on. + This could be very confusing to the user. So give them + a hint as to what might be happening. */ + if (info->gc_sections) + (*info->callbacks->info) + (_("%P: %pB: note: the message above does not take linker garbage collection into account\n"), + hash_entry_bfd (h)); break; } /* Fall through. */ -- cgit v1.1