[PATCH v9 01/19] bfd: rename parsing methods of object attribute v1 API

Jan Beulich jbeulich@suse.com
Fri Oct 24 12:07:08 GMT 2025


On 01.09.2025 18:56, Matthieu Longo wrote:
> This patch is a preparation for the introduction of object attributes
> v2. It aims at:
> - making clear what methods are used to parse OAv1
> - adding more constaints on parameters type by using enums instead of
> defines.
> - hiding the attribute tag type behind a typedef.
> - preparing the move of object attributes's parsing code to another
>   file.
> 
> Note: the name obj_attr_v1_process_attribute is exposed in the API.
> Ideally, the version should not be part of the name, and be hidden
> behind a macro. However, a later patch will unify the parsing of
> OAv1 and OAv2, and will make the use of such a macro obsolete.

Okay, albeit with another minor request:

> --- a/gas/config/obj-elf.c
> +++ b/gas/config/obj-elf.c
> @@ -2075,7 +2075,7 @@ obj_elf_vtable_entry (int ignore ATTRIBUTE_UNUSED)
>  #define skip_whitespace(str)  do { if (is_whitespace (*(str))) ++(str); } while (0)
>  
>  static inline int
> -skip_past_char (char ** str, char c)
> +skip_past_char (char **str, char c)
>  {
>    if (**str == c)
>      {
> @@ -2090,23 +2090,50 @@ skip_past_char (char ** str, char c)
>  /* A list of attributes that have been explicitly set by the assembly code.
>     VENDOR is the vendor id, BASE is the tag shifted right by the number
>     of bits in MASK, and bit N of MASK is set if tag BASE+N has been set.  */
> -struct recorded_attribute_info {
> +typedef struct recorded_attribute_info {
>    struct recorded_attribute_info *next;
> -  int vendor;
> +  obj_attr_vendor_t vendor;
>    unsigned int base;
>    unsigned long mask;
> -};
> -static struct recorded_attribute_info *recorded_attributes;
> +} recorded_attribute_info_t;
> +static recorded_attribute_info_t *recorded_attributes;
> +
> +static void
> +oav1_attr_info_free (recorded_attribute_info_t *node)
> +{
> +  while (node != NULL)
> +    {
> +      recorded_attribute_info_t *next = node->next;
> +      free (node);
> +      node = next;
> +    }
> +}
> +
> +static void
> +oav1_attr_info_init (void)
> +{
> +  /* Note: this "constructor" was added for symetry with oav1_attr_info_exit.
> +     recorded_attributes is a static variable which is automatically initialized
> +     to NULL.  There is no need to initialize it another time except for a
> +     cosmetic reason.  */
> +  recorded_attributes = NULL;
> +}

"... for a cosmetic reason and to possibly help fuzzing."

Also, nit: "symmetry"

Jan


More information about the Binutils mailing list