[PATCH v5 05/20] gas: implement parsing of object attributes v2
Matthieu Longo
matthieu.longo@arm.com
Wed Jul 9 15:05:55 GMT 2025
On 2025-07-09 14:55, Richard Earnshaw (lists) wrote:
> On 07/07/2025 17:49, Matthieu Longo wrote:
>> diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
>> index 1ccbcc40d4d..acf93a3cee5 100644
>> --- a/bfd/elf-attrs.c
>> +++ b/bfd/elf-attrs.c
>> +
>> +/* Return True if the given subsection name is part of the reserved "gnu-testing"
>> + namespace. */
>> +static bool
>> +gnu_testing_namespace (const char *subsec_name)
>> +{
>> + return strncmp ("gnu-testing", subsec_name, 11) == 0;
>
> What's the reason for using strncmp here rather than strcmp?
>
The subsection name can be longer than "gnu-testing" (see example in the
tests), so we need to compare at most len("gnu-testing"), i.e. 11 bytes.
In my understanding, you cannot do this with strcmp.
>> +
>> +extern const obj_attr_info_t *
>> +known_obj_attr_v2_find_by_tag (const struct elf_backend_data *,
>> + const char*, obj_attr_tag_t);
>
> Indentation should be to the level of the opening parenthesis.
>
Fixed in the next revision.
>> +
>> +extern const char *
>> +obj_attr_v2_tag_to_string (const struct elf_backend_data *, const char*,
>> + obj_attr_tag_t);
>
> and here.
>
Fixed in the next revision.
>> +
>> +/* Record a subsection (object attribute v2 only). */
>> +static void
>> +obj_attr_v2_subsection_record (const char *name,
>> + bool optional,
>> + obj_attr_encoding_v2 encoding)
>> +{
>> + obj_attr_subsection_v2 *already_recorded_subsec =
>> + obj_attr_subsection_v2_find_by_name
>> + (elf_obj_attr_subsections (stdoutput).first_, name, false);
>> +
>> + if (already_recorded_subsec != NULL)
>> + {
>> + /* Check for mismatching redefinition of the subsection, i.e. the names
>> + match but the properties are different. */
>> + if ((already_recorded_subsec->optional != optional)
>> + || (already_recorded_subsec->encoding != encoding))
>> + {
>> + as_bad (_("recalled subsections must have the same parameters"));
>> + return;
>
> Even with the source code in front of me, I'm not entirely sure what 'recalled' means in this context. Perhaps a clearer error would be something along the lines of
>
> "Incompatible redeclaration of subsection <name>. Previous declaration had parameters: <list>"
>
> where 'name' and 'list' refer back to the subsection and properties of the subsection we need to match.
>
>
Fixed in the next revision.
>> diff --git a/gas/doc/c-aarch64.texi b/gas/doc/c-aarch64.texi
>> index d7e9c95111d..d88fcdf2da7 100644
>> --- a/gas/doc/c-aarch64.texi
>> +++ b/gas/doc/c-aarch64.texi
>> @@ -460,6 +460,29 @@ The AArch64 architecture uses @sc{ieee} floating-point numbers.
>>
>> @c AAAAAAAAAAAAAAAAAAAAAAAAA
>>
>> +@cindex @code{.aeabi_subsection} directive, AArch64
>> +@item .aeabi_subsection @var{name}, @var{comprehension}, @var{encoding}
>> +Create or switch the current object attributes subsection to @var{name}. Valid
>> +values for @var{name} are following the pattern @code{[a-zA-Z0-9_-]+}.
>> +
>> +@var{comprehension} determines whether the subsection is @code{required} or
>> +@code{optional}. An optional subsection can be skipped if it is not known by the
>> +customer tool, unknown @code{required} subsection should generate an error and
>> +stop the processing.
>
> I think it would be clearer to write something like:
>
> The subsection property @var{comprehension} determines how a program processing
> the attributes handles attributes that it does not recognize (perhaps because the
> object file was generated by a different version of the toolchain). A subsection
> that is marked @code{optional} can be skipped if it is not understood. A
> subsection marked @code{required} implies that information conveyed by the
> attribute is required for correct processing of the object file; a fatal diagnostic
> must be generated if a tool does not recognize either the tag or the value
> associated with it.
>
Fixed in the next revision.
Matthieu
More information about the Binutils
mailing list