[PATCH v4 1/2] ld: bfd: sframe: KEEP .sframe sections and support gc-sections

Jan Beulich jbeulich@suse.com
Tue Jan 27 07:35:04 GMT 2026


On 26.01.2026 16:51, claudiu.zissulescu-ianculescu--- via Binutils wrote:
> @@ -14703,6 +14706,21 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
>  	  fini_reloc_cookie_for_section (&cookie, sec);
>  	  sec = bfd_get_next_section_by_name (NULL, sec);
>  	}
> +
> +      /* Now parse each .sframe section.  Point each .sframe section
> +	 to each bfd.  */

Isn't the latter sentence backwards? You point ...

> +      sec = bfd_get_section_by_name (sub, ".sframe");
> +      while (sec && init_reloc_cookie_for_section (&cookie, info, sec, false))
> +	{
> +	  _bfd_elf_parse_sframe (sub, info, sec, &cookie);
> +
> +	  if (sec->sec_info
> +	      && (sec->flags & SEC_LINKER_CREATED) == 0)
> +	    elf_sframe_section (sub) = sec;

... to the section here, if I'm not mistaken.

> @@ -15302,15 +15320,13 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
>  	  if (!init_reloc_cookie_for_section (&cookie, info, i, false))
>  	    return -1;
>  
> -	  if (_bfd_elf_parse_sframe (abfd, info, i, &cookie))
> +	  _bfd_elf_parse_sframe (abfd, info, i, &cookie);

If the return value of the function becomes irrelevant, the function should
imo be changed to return void. First of course it wants to become clear why
the return value suddenly doesn't matter anymore. The description indeed
mentions this, but in a way that suggests that now the return value should
be checked at the other, new call site. Furthermore "already parsed" isn't
anything the function appears to be handling. Instead it looks as if upon
re-invocation it would do all the work again, leaking what was allocated on
the first run through (and potentially emitting the same error message
again). What am I overlooking?

Imo, if "already parsed" needs handling, it should result in the function
returning true. After all, for the call here
- if it may also not have been called before, its return value would still
  be relevant here,
- if it was guaranteed to have been called before, why would you call it a
  2nd time at all?

Jan


More information about the Binutils mailing list