This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Relax a -r --gc-sections requirement
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 20 Oct 2018 19:47:44 +1030
- Subject: Relax a -r --gc-sections requirement
A symbol root is not needed if --gc-keep-exported is also given.
* ldlang.c (lang_end): Don't error if no --entry or --undefined
is given with -r -gc-sections if --gc-keep-exported.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8d35e0da43..d2b297ce8b 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6383,8 +6383,10 @@ lang_end (void)
warn = TRUE;
/* Force the user to specify a root when generating a relocatable with
- --gc-sections. */
- if (link_info.gc_sections && bfd_link_relocatable (&link_info)
+ --gc-sections, unless --gc-keep-exported was also given. */
+ if (bfd_link_relocatable (&link_info)
+ && link_info.gc_sections
+ && !link_info.gc_keep_exported
&& !(entry_from_cmdline || undef_from_cmdline))
einfo (_("%F%P: gc-sections requires either an entry or "
"an undefined symbol\n"));
--
Alan Modra
Australia Development Lab, IBM