]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld/aarch64elf: add support for DT_AARCH64_MEMTAG_MODE dynamic tag
authorIndu Bhagat <indu.bhagat@oracle.com>
Sat, 12 Jul 2025 09:10:23 +0000 (11:10 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Sat, 12 Jul 2025 09:33:25 +0000 (11:33 +0200)
commit97d71f2366fdbe506bcfad0c0abd3914ba334ada
tree5a42070b9d41b28465e3789ce8b567c53057d3a1
parent427363b461dc40e4e03bef27d2d52623b800f312
ld/aarch64elf: add support for DT_AARCH64_MEMTAG_MODE dynamic tag

Add new command line option -z memtag-mode=<mode> to aarch64 elf,
where <mode> can be one of none, sync, or async.  For mode of sync or
async, a DT_AARCH64_MEMTAG_MODE dynamic tag with a value of 0 or 1
respectively is emitted.

readelf displays the dynamic tag when present:

$ readelf -d <exectutable>
Dynamic section at offset 0xfdd8 contains XX entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000c (INIT)               0x400520
 0x000000000000000d (FINI)               0x400b64
 0x0000000000000019 (INIT_ARRAY)         0x41fdc8
 ...                 ...                 ...
 0x0000000070000009 (AARCH64_MEMTAG_MODE) 0x1
 ...                 ...                 ...

Note that this patch doesn't add support for the "asymm" MTE mode,
which is an Armv8.7 extension.

ChangeLog:

        * bfd/elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Add
new member for memtag properties.
        (bfd_elfNN_aarch64_set_options): New argument to pass memtag
properties.
(elfNN_aarch64_late_size_sections): Emit DT_AARCH64_MEMTAG_MODE
dynamic tag.
        * bfd/elfxx-aarch64.h: New definition for the various memtag
properties.
        * binutils/readelf.c (get_aarch64_dynamic_type): Handle
DT_AARCH64_MEMTAG_MODE.
        * ld/emultempl/aarch64elf.em: Likewise.
        * ld/ld.texi: Add documentation for the new option
-z memtag-mode.
        * ld/testsuite/ld-aarch64/aarch64-elf.exp: New test.
        * ld/testsuite/ld-aarch64/dt-memtag.d: New test.
        * ld/testsuite/ld-aarch64/dt-memtag-mode.s: New test.

include/ChangeLog:

        * elf/aarch64.h (DT_AARCH64_MEMTAG_MODE): New definition.
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.h
binutils/readelf.c
include/elf/aarch64.h
ld/emultempl/aarch64elf.em
ld/ld.texi
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/dt-memtag-mode.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/dt-memtag.s [new file with mode: 0644]