[PATCH] objdump: sframe: fix multiple emission of SFrame and DWARF Frame

Indu Bhagat indu.bhagat@oracle.com
Thu Feb 5 09:04:45 GMT 2026


On 2/4/26 8:08 AM, Jens Remus wrote:
> On 2/3/2026 11:37 PM, Indu Bhagat via Binutils wrote:

>> diff --git a/binutils/objdump.c b/binutils/objdump.c
> 
>> @@ -4983,33 +4979,40 @@ dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED,
>>   #endif
>>   
>>   static void
>> -dump_sframe_section (bfd *abfd, const char *sect_name, bool is_mainfile)
>> +dump_sframe_section (bfd *abfd, const char *sect_name)
>>   
>>   {
>>     /* Error checking for user provided SFrame section name, if any.  */
>> -  if (sect_name)
>> +  asection *sec = bfd_get_section_by_name (abfd, sect_name);
>> +  if (sec == NULL)
>>       {
>> -      asection *sec = bfd_get_section_by_name (abfd, sect_name);
>> -      if (sec == NULL)
>> -	{
>> -	  printf (_("No %s section present\n\n"), sanitize_string (sect_name));
>> -	  return;
>> -	}
>> -      /* Starting with Binutils 2.45, SFrame sections have section type
>> -	 SHT_GNU_SFRAME.  For SFrame sections from Binutils 2.44 or earlier,
>> -	 check explcitly for SFrame sections of type SHT_PROGBITS and name
>> -	 ".sframe" to allow them.  */
>> -      else if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
>> -	       || (elf_section_type (sec) != SHT_GNU_SFRAME
>> -		   && !(elf_section_type (sec) == SHT_PROGBITS
>> -			&& strcmp (sect_name, ".sframe") == 0)))
>> -	{
>> -	  printf (_("Section %s does not contain SFrame data\n\n"),
>> -		  sanitize_string (sect_name));
>> -	  return;
>> -	}
>> +      printf (_("No %s section present\n\n"), sanitize_string (sect_name));
>> +      return;
>> +    }
>> +  /* Starting with Binutils 2.45, SFrame sections have section type
>> +     SHT_GNU_SFRAME.  For SFrame sections from Binutils 2.44 or earlier,
>> +     check explcitly for SFrame sections of type SHT_PROGBITS and name
>> +     ".sframe" to allow them.  */
>> +  else if (bfd_get_flavour (abfd) != bfd_target_elf_flavour
>> +	   || (elf_section_type (sec) != SHT_GNU_SFRAME
>> +	       && !(elf_section_type (sec) == SHT_PROGBITS
>> +		    && strcmp (sect_name, ".sframe") == 0)))
>> +    {
>> +      printf (_("Section %s does not contain SFrame data\n\n"),
>> +	      sanitize_string (sect_name));
>> +      return;
>>       }
>> -  dump_dwarf (abfd, is_mainfile);
>> +
>> +  /* Instead of invoking dump_dwarf () here, load the section and invoke the
>> +     display function directly.  Otherwise, the textual dump may contain
>> +     duplicate output due to two invocations of dump_dwarf ().  See PR
>> +     libsframe/33806.  */
>> +  if (!load_specific_debug_section (sframe, sec, (void*) abfd))
>> +    return;
>> +
>> +  struct dwarf_section *section = &debug_displays[sframe].section;
>> +  section->name = sect_name;
>> +  debug_displays[sframe].display (section, abfd);
> 
> Why not free the loaded section afterwards, as dump_dwarf_section()
> would have done?
> 
>    free_debug_section (sframe);
> 

Hi Jens,

free_debug_memory () invocation takes care of free'ing the debug section 
data (including sframe).  So free_debug_section (sframe) looks unnecessary.

Thanks



More information about the Binutils mailing list