Skip to content

Commit

Permalink
[PAuthABIELF64] Use .note.gnu.property section as ELF marking scheme.
Browse files Browse the repository at this point in the history
Make the alternative .note.gnu.property section the default ELF
marking scheme for ELF executables and shared libraries. Preserve
the original SHT_NOTE section as an alternative for legacy
compatibility.

Tighten up the wording to restrict the property to just a pair
of 64-bit words. This permits the program property to be
described by a pair of build attributes which Arm plans to
introduce for relocatable ELF object marking.
  • Loading branch information
smithp35 committed Jan 29, 2024
1 parent b0f1111 commit 2b752ae
Showing 1 changed file with 78 additions and 49 deletions.
127 changes: 78 additions & 49 deletions pauthabielf64/pauthabielf64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.. _CPPABI64: https://github.com/ARM-software/abi-aa/releases
.. _LSB: https://refspecs.linuxfoundation.org/LSB_1.2.0/gLSB/noteabitag.html
.. _SCO-ELF: http://www.sco.com/developers/gabi/
.. _SYSVABI64: https://github.com/ARM-software/abi-aa/releases
.. _TLSDESC: http://www.fsfla.org/~lxoliva/writeups/TLS/paper-lk2006.pdf
.. _LINUX_ABI: https://github.com/hjl-tools/linux-abi/wiki
.. footer::
Expand Down Expand Up @@ -234,6 +235,8 @@ changes to the content of the document for that release.
| 2023Q3 | 6\ :sup:`th` October 2023 | Update tags in `Dynamic Section`_ to avoid conflict with |
| | | DT_AARCH64_VARIANT_PCS. |
+------------+-----------------------------+------------------------------------------------------------------+
| 2024Q1 | 29\ :sup:`th` January 2024 | Update preferred ELF marking scheme to be GNU property based |
+------------+-----------------------------+------------------------------------------------------------------+

References
----------
Expand All @@ -257,11 +260,14 @@ This document refers to, or is referred to by, the following documents.
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+
| SCO-ELF_ | http://www.sco.com/developers/gabi/ | System V Application Binary Interface – DRAFT |
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+
| SYSVABI64_ | sysvabi64 | System V Application Binary Interface (ABI) for the Arm 64-bit |
| | | Architecture |
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+
| TLSDESC_ | http://www.fsfla.org/~lxoliva/writeups/TLS/paper-lk2006.pdf | TLS Descriptors for Arm. Original proposal document |
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+
| `GABI_SHT_RELR <https://groups.google.com/d/msg/generic-abi/bX460iggiKg/YT2RrjpMAwAJ>`_ | ELF GABI Google Groups | Proposal for a new section type SHT_RELR |
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+
| LINUX_ABI_ | https://github.com/hjl-tools/linux-abi/wiki | Linux Extensions to gABI |
| `LINUX_ABI`_ | https://github.com/hjl-tools/linux-abi/wiki | Linux Extensions to gABI |
+-----------------------------------------------------------------------------------------+-------------------------------------------------------------+--------------------------------------------------------------------------+

Terms and Abbreviations
Expand Down Expand Up @@ -843,29 +849,36 @@ high-level language mapping may result in incompatible ELF files.

This document defines a default ELF marking schema and a base
compatibility model. Platforms may define their own ELF marking and
compatibility model that replace or extend the default ones. `Appendix
Alternative ELF Marking Using GNU Program Properties`_ defines an
alternative marking schema for platforms that support the
``.note.gnu.property`` section.
compatibility model that replace or extend the default ones.

`Appendix Alternative ELF Marking Using SHT_NOTE section`_ defines an
alternative marking schema that uses a generic SHT_NOTE for platforms
that do not support the ``.note.gnu.property`` section.

Default Marking Schema
----------------------

A new section named ``.note.AARCH64-PAUTH-ABI-tag`` of type
``SHT_NOTE`` is defined. This section is structured as a note section
as documented in SCO-ELF_, and its attribute flag ``SHF_ALLOC`` must
be set.
The default ELF marking scheme for executables and shared-libraries
uses the ``.note.gnu.property`` section. The format of this section is
defined in (LINUX_ABI_).

The following processor-specific program property types are defined:

The name field (``namesz`` / ``name``) contains the string "ARM". The
type field shall be 1, and the ``descsz`` field must be at least 16.
The first 16 bytes of the description must contain 2 64-bit words, with
+----------------------------------------+------------+
| Name | Value |
+========================================+============+
| GNU\_PROPERTY\_AARCH64\_FEATURE\_PAUTH | 0xc0000001 |
+----------------------------------------+------------+

Other processor-specific program property types defined by the 64-bit
ABI for the Arm Architecture are defined in (SYSVABI64_).

The format of the data in ``pr_data`` is two 64-bit words. With
the first 64-bit word being a platform identifier, and the second
64-bit word being a version number for the ABI for the platform
identified for the first word. When ``descsz`` is larger than 16 the
remainder of the contents of desc are defined by the (platform id,
version number).
identified for the first word.

The following values of the platform id are reserved:
The following values of the platform identifier are reserved:

+-----------+-----------+
| Platform | Hex value |
Expand All @@ -875,15 +888,18 @@ The following values of the platform id are reserved:
| Baremetal | 0x1 |
+-----------+-----------+

The version number in ``.note.AARCH64-PAUTH-ABI-tag`` is not directly
related to the version number of this document. It is controlled by
the object-producer based on the signing schema that has been used for
The version number for the platform identifier is controlled by the
object-producer based on the signing schema that has been used for
pointers.

If a file contains a section named ``.note.AARCH64-PAUTH-ABI-tag``,
it must observe the entirety of the rules in this default marking
schema. Generating such section with a platform-specific schema is
forbidden.
This ABI reserves the combination of (platform identifier, version
number) equal to (0,0) to represent an ELF file incompatible with this
ABI.

.note.gnu.properties are defined for relocatable objects. Arm intends
to use build-attributes for relocatable-object ELF marking. This will
be defined so that there is a 1:1 mapping between the program
property and the build-attributes for PAuthABI.

Base Compatibility Model
------------------------
Expand Down Expand Up @@ -1236,33 +1252,46 @@ Some observations:
pointer signing information in a custom encoding understood by the
start-up code used.

Appendix Alternative ELF Marking Using GNU Program Properties
=============================================================
Appendix Alternative ELF Marking Using SHT_NOTE section
=======================================================

If a platform supports section ``.note.gnu.property``, this can be used
as the base for an alternative schema. The format of this section is
defined in LINUX_ABI_.
A new section named ``.note.AARCH64-PAUTH-ABI-tag`` of type
``SHT_NOTE`` is defined. This section is structured as a note section
as documented in SCO-ELF_, and its attribute flag ``SHF_ALLOC`` must
be set.

The following processor-specific program property types are defined:
The ``namesz`` field shall be 4

+----------------------------------------+------------+
| Name | Value |
+========================================+============+
| GNU\_PROPERTY\_AARCH64\_FEATURE\_PAUTH | 0xc0000001 |
+----------------------------------------+------------+
The ``descsz`` field must be at least 16. See ``desc`` below.

The type field shall be ``NT_ARM_TYPE_PAUTH_ABI_TAG``, defined to the
value 1.

The ``name`` field shall be the null-terminated string ``ARM``.

The first 16 bytes of the ``desc`` contain 2 64-bit words, with
the first 64-bit word being a platform identifier, and the second
64-bit word being a version number for the ABI for the platform
identified for the first word. When ``descsz`` is larger than 16 the
remainder of the contents of desc are defined by the (platform id,
version number).

The following values of the platform id are reserved:

+-----------+-----------+
| Platform | Hex value |
+===========+===========+
| Invalid | 0x0 |
+-----------+-----------+
| Baremetal | 0x1 |
+-----------+-----------+

The version number in ``.note.AARCH64-PAUTH-ABI-tag`` is not directly
related to the version number of this document. It is controlled by
the object-producer based on the signing schema that has been used for
pointers.

The format of the data in ``pr_data`` is at least two 64-bit words,
the first being a platform identifier, and the second being a version
number specific to the platform identified in the first word.
Consequently, the ``pr_datasz`` field must be at least 16. When
``pr_datasz`` is larger than 16, the remainder of the contents of
``pr_data`` are specific to the (platform id, version number). If
``pr_datasz`` is not a multiple of 8, ``pr_padding`` must be added so
that PR_DATASZ + PR_PADDING is a multiple of 8 and the property
remains 8-byte aligned.

The rules for the fields are the same as for the default marking
schema: this ABI does not define the exact format of the platform and
version identifiers, but reserves the combination of (platform,
version) equal to (0,0) to represent an ELF file incompatible with
this ABI.
If a file contains a section named ``.note.AARCH64-PAUTH-ABI-tag``,
it must observe the entirety of the rules in this default marking
schema. Generating such section with a platform-specific schema is
forbidden.

0 comments on commit 2b752ae

Please sign in to comment.