link_info.init_function & link_info.fini_function are GC roots. When they are explicitly specified, there is no need for the error: % ld.bfd -r --gc-sections -init _init a.o ld.bfd: gc-sections requires either an entry or an undefined symbol
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2f5541f384babda4aef3d6c8011a6d15af78e0a3 commit 2f5541f384babda4aef3d6c8011a6d15af78e0a3 Author: Alan Modra <amodra@gmail.com> Date: Mon Jul 20 13:32:34 2020 +0930 PR26265, Spurious 'gc-sections requires ... when --init or --fini bfd/ * elflink.c (_bfd_elf_gc_keep): Use bfd_is_const_section. ld/ PR 26265 * ldlang.c (undef_from_cmdline): Delete. (ldlang_add_undef): Mark "cmdline" param unused. (lang_end): Traverse gc_sym_list to determine whether a symbol root has been specified. Update error message. * testsuite/ld-gc/noent.d: Adjust for changed error message.
Fixed.