]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd: parse Object Attributes v2's section in input object files
authorMatthieu Longo <matthieu.longo@arm.com>
Thu, 1 May 2025 16:42:33 +0000 (17:42 +0100)
committerMatthieu Longo <matthieu.longo@arm.com>
Thu, 22 Jan 2026 10:11:16 +0000 (10:11 +0000)
commit021dde54836d5161ce7222839da45eb55e9407e5
treebd6df2a3618fd98570e7b8cdc6af19183c24eaf2
parent977832208cdada94d870209c43710eef584daef0
bfd: parse Object Attributes v2's section in input object files

This patch adds to BFD the capability of parsing the Object Attributes v2
(OAv2) stored into the section defined by the backend (i.e. .ARM.attributes
for AArch64).

An OAv2 section is organized with the following syntactic structure:
  <format-version: uint8>
  [ <subsection-length: uint32>
    <subsection-name: NTBS>
    <optionality: uint8>
    <encoding: uint8>
    <attribute>*
  ]*

Once parsing is completed, OAv2 are stored in a list of subsections in
elf_obj_tdata.

Regarding ULEB128 parsing, the implementation of _bfd_safe_read_leb128
has known shortcomings. In particular, it may accept malformed ULEB128
values if the 8th bit is set while meeting the end condition "data < end".
The error handling could be improved, but this function is old and used
in more than 50 places. The same issue applies to _bfd_read_unsigned_leb128
and _bfd_read_signed_leb128, which likewise do not report errors in
this case. Since this is long-standing behavior and fixing it would
require broader changes outside the scope of this patch series, the
issue is acknowledged but not addressed here, and is considered
acceptable as this patch does not worsen the situation.
bfd/elf-attrs.c