[PATCH v0 05/15] bfd: write object attributes v2

Jan Beulich jbeulich@suse.com
Tue Mar 11 08:10:19 GMT 2025


On 10.03.2025 18:51, Matthieu Longo wrote:
> --- a/bfd/elf-attrs.c
> +++ b/bfd/elf-attrs.c
> @@ -118,7 +118,51 @@ bfd_elf_obj_attrs_v1_size (bfd *abfd)
>    size = vendor_obj_attrs_v1_size (abfd, OBJ_ATTR_PROC);
>    size += vendor_obj_attrs_v1_size (abfd, OBJ_ATTR_GNU);
>    if (size > 0)
> -    size += sizeof(uint8_t); /* <format-version: ‘A’>  */
> +    size += sizeof(uint8_t); /* <format-version: 'A'>  */
> +  return size;
> +}
> +
> +/* Return the size of a single attribute.  */
> +static bfd_vma
> +obj_attr_v2_size (obj_attr_v2 *attr, obj_attr_encoding_v2 type)
> +{
> +  bfd_vma size;
> +
> +  size = uleb128_size (attr->tag);
> +  if (type == ULEB128)
> +    size += uleb128_size (attr->vals.uint_val);
> +  if (type == NTBS)
> +    size += strlen (attr->vals.string_val) + 1; // +1 for '\0'
> +  return size;
> +}
> +
> +/* Return the size of a subsection.  */
> +static bfd_vma
> +obj_attr_subsection_v2_size (obj_attr_subsection_v2 *subsec)
> +{
> +  bfd_vma size = sizeof(uint32_t); // <uint32: subsection-length>
> +  size += strlen (subsec->name) + 1; // NTBS: vendor-name so +1 for '\0'
> +  size += 2 * sizeof(uint8_t); // <uint8: optional> <uint8: parameter type>
> +  // <attribute>*

Style nit (again here and elsewhere): Style-conforming comments please.

Jan


More information about the Binutils mailing list