* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
@ifset ELF
* Gnu_attribute:: @code{.gnu_attribute @var{tag},@var{value}}
+* Gnu_subsection:: @code{.gnu_subsection @var{name}, @var{comprehension}, @var{encoding}}
* Hidden:: @code{.hidden @var{names}}
@end ifset
@ifset ELF
@node Gnu_attribute
@section @code{.gnu_attribute @var{tag},@var{value}}
-Record a @sc{gnu} object attribute for this file. @xref{Object Attributes}.
+
+For Object Attributes v1, record a @sc{gnu} object attribute with the pair
+@var{tag}, @var{value} for this file.
+
+For Object Attributes v2, record an object attribute with the pair @var{tag},
+@var{value} in the current subsection for this file.
+
+@var{tag} can either be an integer value, or a known named key. @var{value} can
+either be an integer or a string. For Object Attribute v2, the expected value
+type depends on the type set on the subsection.
+
+@xref{Object Attributes}.
+
+@node Gnu_subsection
+@section @code{.gnu_subsection @var{name}, @var{comprehension}, @var{encoding}}
+Create or switch the current object attributes subsection to @var{name} for This
+file. Valid values for @var{name} are following the pattern @code{[a-zA-Z0-9_]+}.
+
+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.
+
+@var{encoding} specifies the expected encoding of the attributes recorded in the
+subsection. Currently supported values are @code{ULEB128}/@code{uleb128} and
+@code{NTBS}/@code{ntbs} (null-terminated byte string).
+
+On the first declaration of a subsection, both @var{comprehension} and
+@var{encoding} are mandatory parameters. However, on subsequent declarations,
+none of the parameters is required. If they are still specified, their values
+will be matched against the ones from the first declaration. Any mismatch will
+be reported as an error.
+
+This directive is only available for Object Attributes v2.
+
+@xref{Object Attributes}.
@node Hidden
@section @code{.hidden @var{names}}
point arguments might be passed in floating point registers if the object file
requires hardware floating point support---or floating point arguments might be
passed in integer registers if the object file supports processors with no
-hardware floating point unit. Or, if two objects are built for different
-generations of the same architecture, the combination may require the
-newer generation at run-time.
+hardware floating point unit. Another example might be when two object files
+make use of different architectural extensions: the final image will require
+both features to be supported at runtime; or if the features are mutually
+exclusive, the linker can issue a diagnostic.
-This information is useful during and after linking. At link time,
-@command{@value{LD}} can warn about incompatible object files. After link
-time, tools like @command{gdb} can use it to process the linked file
-correctly.
-
-Compatibility information is recorded as a series of object attributes. Each
-attribute has a @dfn{vendor}, @dfn{tag}, and @dfn{value}. The vendor is a
-string, and indicates who sets the meaning of the tag. The tag is an integer,
-and indicates what property the attribute describes. The value may be a string
-or an integer, and indicates how the property affects this object. Missing
-attributes are the same as attributes with a zero value or empty string value.
+@command{@value{AS}} currently supports two versions of object attributes:
+@itemize @bullet{}
+@item
+Object Attributes version 1 (OAv1) used by: ARC, ARM, C-SKY, MIPS, MSP430, M68K,
+PowerPC, RISC-V, SPARC, s390, and TIC6X.
+@item
+Object Attributes version 2 (OAv2) used by: AArch64.
+@end itemize
-Object attributes were developed as part of the ABI for the ARM Architecture.
-The file format is documented in @cite{ELF for the ARM Architecture}.
+Object attributes are only supported when generating ELF format.
@menu
+* Object Attributes v1:: Object Attributes v1
+* Object Attributes v2:: Object Attributes v2
* GNU Object Attributes:: @sc{gnu} Object Attributes
* Defining New Object Attributes:: Defining New Object Attributes
@end menu
+@node Object Attributes v1
+@section Object Attributes v1
+
+In Object Attributes v1 (OAv1) Compatibility information is recorded as a series
+of object attributes. Each attribute has a @dfn{vendor}, @dfn{tag}, and
+@dfn{value}. The @dfn{vendor} is a string, and indicates who sets the meaning
+of the tag. The @dfn{tag} is an integer, and indicates what property the
+attribute describes. The @dfn{value} may be a string or an integer, and
+indicates how the property affects this object. Integer tags generally default
+to 0, while string tags default to the empty string. Tags are only recorded in
+the file if they have a non-default value.
+
+OAv1 were developed as part of the ABI for the ARM Architecture. The file
+format is documented in @cite{Addenda to, and Errata in, the ABI for the Arm
+Architecture}.
+
+@node Object Attributes v2
+@section Object Attributes v2
+
+Object Attributes v2 (OAv2) share common concepts of @dfn{vendor}, @dfn{tag}
+and @dfn{value} with OAv1, but also introduce the new ones like @dfn{subsection}
+and @dfn{scope}. Attributes with common properties are grouped into subsections.
+All the attributes in a subsection share the same encoding, comprehension, and
+scope. A subsection starting with the vendor name is considered public. The
+value of an attribute may be a string or an integer depending on the encoding
+set on its subsection.
+
+The file format used by OAv2 is documented in @cite{Build Attributes for the
+Arm 64-bit Architecture (AArch64)}, as AArch64 introduced it first.
+
@node GNU Object Attributes
-@section @sc{gnu} Object Attributes
+@section @sc{gnu} Object Attributes (OAv1 only)
The @code{.gnu_attribute} directive records an object attribute
with vendor @samp{gnu}.