[PATCH] ld: Add -z start-stop-gc to let __start_/__stop_ not retain C identifier name sections

Alan Modra amodra@gmail.com
Sun Feb 28 04:20:32 GMT 2021


On Sat, Feb 27, 2021 at 12:26:17PM -0800, Fangrui Song wrote:
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -8089,7 +8089,7 @@ lang_process (void)
>    /* Give initial values for __start and __stop symbols, so that  ELF
>       gc_sections will keep sections referenced by these symbols.  Must
>       be done before lang_do_assignments below.  */
> -  if (config.build_constructors)
> +  if (config.build_constructors && !link_info.start_stop_gc)
>      lang_init_start_stop ();
>  
>    /* PR 13683: We must rerun the assignments prior to running garbage

This will mean start/stop symbols are not defined, which is rather
more than your stated aim of changing the behaviour of garbage
collection.  Not setting h->start_stop in bfd_elf_define_start_stop
would do what you want, I think.  (I haven't checked..)

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list