[PATCH v12 06/25] readelf: dump Object Attributes v2

Jan Beulich jbeulich@suse.com
Mon Jan 19 12:06:32 GMT 2026


On 19.01.2026 13:02, Jan Beulich wrote:
> On 16.01.2026 19:59, Matthieu Longo wrote:
>> +  /* Note: at this stage,
>> +     1. the length of the subsection name is validated, as the presence of '\0'
>> +	at the end of the string, so no risk of buffer overrun.
>> +     2. the data for comprehension and encoding can also safely be read.  */
>> +  unsigned char *const end = cursor + subsection_len - F_SUBSECTION_LEN;
>> +  while (cursor < end)
>> +    {
>> +      const char *subsec_name = (const char *) cursor;
>> +      printf (_(" - Name:	  %s\n"), subsec_name);
>> +      /* The code below needs to be kept in sync with the code of
>> +	 bfd_elf_obj_attr_subsection_v2_scope() in bfd/elf-attrs.c.  */
>> +      size_t public_name_len = strlen (public_name);
>> +      bool public_subsection
>> +	= strncmp (subsec_name, public_name, public_name_len) == 0
>> +	  && subsec_name[public_name_len] == '_';
>> +      cursor += subsection_name_len;
>> +      op.read += subsection_name_len;
>> +
>> +      printf (_("   Scope:	  %s\n"),
>> +	      public_subsection ? "public" : "private");
>> +      printf (_("   Length:	  %u\n"), subsection_len);
>> +
>> +      uint8_t optional;
>> +      READ_ULEB (optional, cursor, end);
>> +      op.read += 1;
> 
> Can you remind me again why READ_ULEB() is used here (and again further down)
> to read a single byte?

And indeed the next patch uses bfd_get_8() in the respective two places. Which
one is it, really?

Jan


More information about the Binutils mailing list