Skip to content

Commit 205b12b

Browse files
committed
[buildattr64] Review comments from initial implementations
* In assembly syntax use a comma in [,optional]. * Change document status to Beta quality. * Remove superfluous Encoding from start of sentence. * Clarification of "optional" in public subsection header. * Clarification that public subsections define their own attributes. * Clarify static linker responsibilities with mixed build attributes. and .note.gnu.property sections. * Reformat the aeabi-pauthabi section to match aeabi-feature-and-bits. * Move and expand the tool interface section from the rationale to the specification.
1 parent ede7d6d commit 205b12b

File tree

2 files changed

+224
-116
lines changed

2 files changed

+224
-116
lines changed

buildattr64/buildattr64.rst

+217-58
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ The following support level definitions are used by the Arm ABI specifications:
193193
The content of this specification is a draft, and Arm considers the
194194
likelihood of future incompatible changes to be significant.
195195

196-
This document is at **Alpha** release quality.
196+
This document is at **Beta** release quality.
197197

198198
Change history
199199
^^^^^^^^^^^^^^
@@ -203,11 +203,19 @@ changes to the content of the document for that release.
203203

204204
.. table::
205205

206-
+------------+---------------------+------------------------------------------------------------------+
207-
| Issue | Date | Change |
208-
+============+=====================+==================================================================+
209-
| 0.1 | 18th October 2023 | Alpha draft release for public comment |
210-
+------------+---------------------+------------------------------------------------------------------+
206+
+------------+---------------------+---------------------------------------------------------------------+
207+
| Issue | Date | Change |
208+
+============+=====================+=====================================================================+
209+
| 0.1 | 18th October 2023 | Alpha draft release for public comment |
210+
+------------+---------------------+---------------------------------------------------------------------+
211+
| 0.2 | 14th November 2024 | Updates after feedback from initial implementation. |
212+
| | | Specification now at Beta |
213+
| | | Clarification of "optional" in public subsection header |
214+
| | | Clarification that public subsections define their own attributes |
215+
| | | Clarify static linker responsibilities with mixed build attributes |
216+
| | | and .note.gnu.property sections. |
217+
| | | Tool Interface for aeabi subsections taken from rationale document. |
218+
+------------+---------------------+---------------------------------------------------------------------+
211219

212220
References
213221
----------
@@ -610,9 +618,9 @@ Representing build attributes in a relocatable ELF Object file
610618
Encoding
611619
--------
612620

613-
Encoding build attributes are encoded in a vendor-specific section of
614-
type ``SHT_AARCH64_ATTRIBUTES`` and name ``.ARM.attributes`` (for
615-
further details see [AAELF64_]).
621+
Build attributes are encoded in a vendor-specific section of type
622+
``SHT_AARCH64_ATTRIBUTES`` and name ``.ARM.attributes`` (for further
623+
details see [AAELF64_]).
616624

617625
An attribute is encoded in a <tag, value> pair.
618626

@@ -652,11 +660,20 @@ An ELF Attributes section uses a processor specific section with details
652660
| ``.ARM.attributes`` | ``SHT_AARCH64_ATTRIBUTES`` | 0x0 | 1 | 0 | 0 |
653661
+---------------------+----------------------------+-------+-----------+------+------------+
654662

655-
A consumer may not assume the natural alignment of a data type such as ``uint32``.
663+
In the contents of an ELF attributes section, a consumer may not assume
664+
the natural alignment of a data type such as ``uint32``.
665+
666+
An attributes section contains a sequence of subsections. Each
667+
subsection is either
668+
669+
* A public subsection defined by this ABI and public to all tools that
670+
process the file.
671+
672+
* A private subsection that is private to a tool vendor's tools.
656673

657674
The syntactic structure of an attributes section is::
658675

659-
<format-version: <version-letter>>
676+
<format-version: ‘A’>
660677
[ <uint32: subsection-length> NTBS: vendor-name
661678
<bytes: vendor-data>
662679
]*
@@ -695,8 +712,8 @@ data in a second pass.
695712
Public aeabi prefixed subsections
696713
=================================
697714

698-
About public tags
699-
-----------------
715+
About public subsections
716+
------------------------
700717

701718
Subsections containing a vendor name with a prefix of "aeabi" are
702719
public attributes defined by this specification. All public aeabi
@@ -707,6 +724,10 @@ A consumer must be able to parse the header of all subsections that
707724
have a prefix of "aeabi". If the header is optional then a consumer
708725
may skip the subsection if they do not recognize the full vendor-name.
709726

727+
All public subsections must have a unique vendor name.
728+
729+
Each public subsection defines its own attribute tags.
730+
710731
Default values for public tags
711732
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
712733

@@ -725,6 +746,7 @@ attributes.
725746
*optional* is a 1-byte integer. It encodes whether the subsection
726747
contents can be safely skipped if the consumer does not recognize the
727748
vendor-name, or if any subset of the subsection can be skipped over.
749+
728750
The permitted values are::
729751

730752
*0* not optional. The consumer must understand the subsection
@@ -733,6 +755,7 @@ The permitted values are::
733755
*1* optional. The consumer may skip the subsection in full or in part
734756
and the program will still be correct.
735757

758+
736759
*parameter type* is a 1-byte integer. It encodes whether the values in
737760
the subsection are ULEB128 values or NTBS. The permitted values are::
738761

@@ -744,6 +767,12 @@ the subsection are ULEB128 values or NTBS. The permitted values are::
744767
unsigned LEB128 encoding (ULEB128), and value is encoded as described
745768
by *parameter type*.
746769

770+
A subsection that is ``not optional`` must be processed in full. A
771+
subsection this ABI defines as ``not optional`` is not required to be
772+
present in the relocatable object file, the rules for `Default values
773+
for public tags`_ apply.
774+
775+
747776
How this specification describes public attributes
748777
--------------------------------------------------
749778

@@ -758,7 +787,11 @@ follows. ::
758787
Block commentary about the tag and its possible values.
759788

760789
*Tag value* gives the numerical representation of the tag. It is a
761-
small integer less than 128.
790+
small integer less than 128. The *Tag value* is meaningful only within
791+
the subsection it is defined within.
792+
793+
*Tag_tag_name* is the human readable representation of the tag value
794+
for use by tools that produce or consume build attributes.
762795

763796
Following lines enumerate the currently defined parameter values,
764797
giving a short comment about each one.
@@ -816,6 +849,55 @@ attributes
816849
0 Not all executable sections are compatible with the guarded control stack extension or no information available.
817850
1 All executable sections are compatible with the guarded control stack extension.
818851

852+
aeabi-feature-and-bits and GNU Program Properties
853+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
854+
855+
GNU Program Properties as defined by [LINUX_ABI_] are a similar
856+
concept to Build Attributes. Program properties are encoded in
857+
``.note.gnu.property`` sections. A static linker combines the program
858+
properties according to the rules for each program property type. The
859+
combined ``.note.gnu.property`` section is written to the loadable-unit.
860+
861+
Build attributes replace the use of GNU program properties for
862+
relocatable object files. A platform may choose to use GNU program
863+
properties to represent properties in loadable-units with static
864+
linkers translating from a merged build attribute value to a GNU
865+
program property.
866+
867+
Many existing relocatable object files have a ``.note.gnu.property``
868+
section with the ``GNU_PROPERTY_AARCH64_FEATURE_1_AND`` program
869+
property.
870+
871+
If a static linker has a subset of the relocatable objects using
872+
``.note.gnu.property`` sections with
873+
``GNU_PROPERTY_AARCH64_FEATURE_1_AND`` program property, and a subset
874+
of the relocatable objects using build attributes. Then the program
875+
properties must be translated into build attributes using the mapping
876+
below.
877+
878+
+--------------------------------------------+---------------------------+
879+
+ Feature bit set in relocatable object file | Equivalent tag = value |
880+
+============================================+===========================+
881+
+ *GNU_PROPERTY_AARCH64_FEATURE_1_BTI* | Tag_Feature_BTI = 1 |
882+
+--------------------------------------------+---------------------------+
883+
+ *GNU_PROPERTY_AARCH64_FEATURE_1_PAC* | Tag_Feature_PAC = 1 |
884+
+--------------------------------------------+---------------------------+
885+
+ *GNU_PROPERTY_AARCH64_FEATURE_1_GCS* | Tag_Feature_GCS = 1 |
886+
+--------------------------------------------+---------------------------+
887+
888+
A relocatable object file may have a ``.note.gnu.property`` section
889+
and ``.ARM.attributes`` sections. When both program properties and
890+
build attributes exist within the same relocatable object, the
891+
relocatable object file is not well formed if a build attribute from
892+
the ``.ARM.attributes`` has a different value when translated from
893+
``.note.gnu.property``. It is QoI whether a static linker uses the
894+
build attributes in preference to the ``.note.gnu.property`` section,
895+
or does the translation and produces a diagnostic.
896+
897+
For a platform that uses GNU Program Properties in loadable-units the
898+
mapping table above can be used to translate build attributes back to
899+
GNU properties.
900+
819901
Pointer Authentication Signing Schema
820902
-------------------------------------
821903

@@ -825,31 +907,41 @@ The (PAUTHABI64_) defines an extension to ELF in which code pointers
825907
are signed using instructions in the FEAT_PAuth extension. The
826908
pointers that are signed as well as the modifiers and key used for
827909
each type of pointer are known as the signing schema. To make use of
828-
(PAuthABI64_) all relocatable object files and shared-library dependencies
829-
must use the same signing schema.
910+
(PAuthABI64_) all relocatable object files and shared-library
911+
dependencies must use the same signing schema.
830912

831913
While the requirement for the ``FEAT_PAuth`` extension is recorded in
832914
the architectural features. The signing schema is software defined
833915
with more complex compatibility requirements.
834916

917+
header contents
918+
^^^^^^^^^^^^^^^
919+
920+
*optional* is 0 (not optional)
921+
922+
*parameter type* is 0 (ULEB128)
923+
924+
attributes
925+
^^^^^^^^^^
926+
835927
::
836928
Tag_PAuth_Platform (=1)
837929
0 The user did not permit this entity to use the PAuthABI, or no information available.
838930
<id> The platform vendor id.
839931

840-
Where the *<id>* is one of a number of registered platforms.
932+
Where the *<id>* is a number representing one of a number of
933+
registered platforms defined in ``PAuthABI64_``.
841934

842935
::
843936
Tag_PAuth_Schema (=2)
844937
0 The user did not permit this entity to use the PAuthABI, or no information available.
845938
<id> The version number of the Schema.
846939

847-
Where the *<id>* is the version number in the context of
848-
``Tag_PAuth_Platform``.
940+
Where the *<id>* is a number representing the version in the context
941+
of ``Tag_PAuth_Platform``.
849942

850-
The signing schema is not optional.
851-
852-
The parameter type is ULEB128.
943+
Combining attribute values of aeabi-pauthabi
944+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
853945

854946
The partial order is custom. Two entities are compabitible if both
855947
``Tag_PAuth_Platform`` and ``Tag_PAuth_Schema`` are identical.
@@ -858,47 +950,114 @@ The compatibility between an entity with ``Tag_PAuth_Platform`` = 0,
858950
``Tag_PAuth_Schema`` = 0, and ``Tag_Pauth_Platform`` != 0, ``Tag_PAuth_Schema`` !=
859951
0 is implementation defined.
860952

861-
aeabi-feature-and-bits and GNU Program Properties
862-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
953+
Private subsections
954+
-------------------
863955

864-
GNU Program Properties as defined by [LINUX_ABI_] are a similar
865-
concept to Build Attributes. Program properties are encoded in
866-
``.note.gnu.property`` sections. A static linker combines the program
867-
properties according to the rules for each program property type. The
868-
combined ``.note.gnu.property`` section is written to the loadable-unit.
956+
No requirements are placed on the format of private vendor data.
869957

870-
Build attributes replace the use of GNU program properties for
871-
relocatable object files. A platform may choose to use GNU program
872-
properties to represent properties in loadable-units with static
873-
linkers translating from a merged build attribute value to a GNU
874-
program property.
958+
Appendix: Tool Interface for aeabi subsections
959+
==============================================
875960

876-
Many existing relocatable object files have a ``.note.gnu.property``
877-
section with the ``GNU_PROPERTY_AARCH64_FEATURE_1_AND`` program
878-
property.
961+
The tool interface presented below describes the interface for GNU and
962+
GNU compatible toolchains.
879963

880-
A relocatable object file may have a ``.note.gnu.property`` section
881-
and ``.ARM.attributes`` sections. When both program properties and
882-
build attributes exist, the program properties must be translated into
883-
build attributes using the mapping below. The relocatable object file
884-
is not well formed if a build attribute from the ``.ARM.attributes``
885-
has a different value when translated from ``.note.gnu.property``.
964+
Compiler
965+
--------
886966

887-
+--------------------------------------------+---------------------------+
888-
+ Feature bit set in relocatable object file | Equivalent tag = value |
889-
+============================================+===========================+
890-
+ *GNU_PROPERTY_AARCH64_FEATURE_1_BTI* | Tag_Feature_BTI = 1 |
891-
+--------------------------------------------+---------------------------+
892-
+ *GNU_PROPERTY_AARCH64_FEATURE_1_PAC* | Tag_Feature_PAC = 1 |
893-
+--------------------------------------------+---------------------------+
894-
+ *GNU_PROPERTY_AARCH64_FEATURE_1_GCS* | Tag_Feature_GCS = 1 |
895-
+--------------------------------------------+---------------------------+
967+
Build attributes are set by the compiler based on command-line
968+
options. For example the clang and gcc ``-mbranch-protection`` option
969+
can be used to derive ``Tag_Feature_BTI`` and ``Tag_Feature_PAC`` and
970+
``Tag_Feature_GCS``.
896971

897-
For a platform that uses GNU Program Properties in loadable-units the
898-
mapping table above can be used to translate build attributes back to
899-
GNU properties.
972+
Individual functions can be given different values from the file scope
973+
command-line options. The file scope build attributes should still be
974+
derived from the file scope command-line options, or module level encodings
975+
of the file scope command-line options in the case of link time optimization.
976+
It is the user's responsibility that the individual functions are used in a
977+
compatible way to the file scope build attributes.
900978

901-
Private subsections
902-
-------------------
979+
Assembler
980+
---------
981+
982+
Where possible the assembler can derive build attributes from the
983+
assembler's command line options in the same way as the compiler. For
984+
options that cannot be derived, assembler directives can be used to
985+
construct "aeabi" prefixed subsections. The assembler directives take
986+
precedence over any derived attributes.
987+
988+
Directives
989+
^^^^^^^^^^
990+
991+
::
992+
.aeabi_subsection name [, optional] [, parameter type]
993+
994+
*name*
995+
996+
Create or switch the current subsection to *name*.
997+
998+
*optional*
999+
1000+
This field is optional and only applies to subsection names with a
1001+
prefix of "aeabi". The default value is 1 for optional.
1002+
1003+
*parameter type*
1004+
1005+
This field is an integer 0 or 1 that determines whether the subsection
1006+
value is ULEB128 or a NTBS. It only applies to subsection names with a
1007+
prefix of "aeabi". The default value is 0 for ULEB128. If *parameter
1008+
type* is not the default then optional must be also be specified even
1009+
if it is the default value.
1010+
1011+
::
1012+
1013+
.aeabi_attribute tag, value
1014+
1015+
* *tag* is either the ``Tag_tag_name`` such as ``Tag_Feature_GCS`` or
1016+
the ``tag value``.
1017+
1018+
* *value* is either a `number` or a "string" depending on the
1019+
``<parameter type>`` of the current subsection.
1020+
1021+
In the current active subsection, set *tag* to *value*.
1022+
1023+
It is an error if .aebi_attribute is encountered when the current
1024+
aeabi subsection is undefined.
1025+
1026+
Directive examples
1027+
^^^^^^^^^^^^^^^^^^
1028+
1029+
Produces a single subsection with 3 attributes set. The default values
1030+
for *optional* and *parameter-type* (1 and 0 respectively) match the
1031+
required values for aeabi-feature-and-bits. The .aeabi_attributes use
1032+
the human readable ``Tag_tag_name``.
1033+
1034+
.. code-block:: asm
1035+
1036+
.aeabi_subsection aeabi-feature-and-bits
1037+
.aeabi_attribute Tag_Feature_BTI, 1
1038+
.aeabi_attribute Tag_Feature_PAC, 1
1039+
.aeabi_attribute Tag_Feature_GCS, 1
1040+
1041+
This translates to the following .ARM.attributes section contents for
1042+
a little-endian relocatable object:
1043+
1044+
`A`, <length 0x23,0x0,0x0,0x0>, "aeabi-feature-and-bits", 1, 0, 0, 1, 1, 1, 2, 1
1045+
1046+
1047+
Produces two subsections. The values for *optional* and
1048+
*parameter-type* have been given explicitly. Numbers have been used to
1049+
set the tag values with comments showing the human readable names.
1050+
1051+
.. code-block:: asm
1052+
1053+
.aeabi_subsection aeabi-feature-and-bits, 1, 0
1054+
.aeabi_attribute 0 /*Tag_Feature_GCS*/, 1
1055+
1056+
.aeabi_subsection aeabi-pauthabi, 0, 0
1057+
.aeabi_attribute 0 /*Tag_PAuth_Platform*/, 1
1058+
.aeabi_attribute 1 /*Tag_Pauth_Schema*/, 1
1059+
1060+
This translates to the following .ARM.attributes section contents for
1061+
a little-endian relocatable object:
9031062

904-
The tool interface for private subsections is implementation defined.
1063+
`A`, <length 0x1e,0x0,0x0,0x0>, "aeabi-feature-and-bits", 1, 0, 2, 1, <length 0x21, 0x0, 0x0, 0x0>, "aeabi-feature-pauthabi", 0, 0, 0, 1, 1, 1

0 commit comments

Comments
 (0)