Skip to content

Commit

Permalink
Merge branch 'ARM-software:main' into pauthaaelf64relocs
Browse files Browse the repository at this point in the history
  • Loading branch information
smithp35 authored Aug 20, 2024
2 parents 480984b + 201a7cb commit c87b0b1
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 99 deletions.
2 changes: 1 addition & 1 deletion aaelf32/aaelf32.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ The following nomenclature is used for the operation:
+---------+----------------------------------+------------+---------------+----------------------------------------+
| 2 | :code:`R_ARM_ABS32` | Static | Data | :code:`(S + A) | T` |
+---------+----------------------------------+------------+---------------+----------------------------------------+
| 3 | :code:`R_ARM_REL32` | Static | Data | :code:`((S + A) | T) | – P` |
| 3 | :code:`R_ARM_REL32` | Static | Data | :code:`((S + A) | T) – P` |
+---------+----------------------------------+------------+---------------+----------------------------------------+
| 4 | :code:`R_ARM_LDR_PC_G0` | Static | Arm | :code:`S + A – P` |
+---------+----------------------------------+------------+---------------+----------------------------------------+
Expand Down
50 changes: 30 additions & 20 deletions aaelf64/aaelf64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,15 @@ A ``RELA`` format relocation must be used if the initial addend cannot be encode

There is no PC bias to accommodate in the relocation of a place containing an instruction that formulates a PC- relative address. The program counter reflects the address of the currently executing instruction.

There are two special cases for forming the initial addend of REL-type relocations where the immediate field cannot normally hold small signed integers:

* For relocations processing MOVZ and MOVK instructions (including the "MOV (wide immediate)" alias), the initial addend is formed by interpreting the 16-bit literal field of the instruction as a 16-bit signed value in the range -32768 <= A < 32768. The interpretation is the same whether or not the instruction applies a left shift to its immediate: the addend is never treated as shifted.

* For relocations processing the ADRP instruction, the initial addend is similarly formed by interpreting the literal field of the instruction as a 21-bit signed integer, in the range -1048576 <= A < 1048576. The ADRP instruction's implicit left shift of 12 bits is not applied.

These special cases permit a sequence of instructions to each add the same small constant to a symbol's value, and extract separate ranges of bits from the sum, so that the instruction sequence as a whole consistently loads the full result of the addition.

In the case of a sequence using ADRP followed by a 12-bit ADD to set up the low bits of the offset, you can express an offset up to 1048576 in either direction, by writing the full offset in the ADRP's immediate field, and repeating its low 12 bits in the ADD's immediate field. A linker resolving the R_AARCH64_ADD_ABS_LO12_NC relocation on the ADD will not compute the correct overall 64-bit value, but the error will only be in the higher bits, which are discarded by that relocation.

Relocation types
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1027,6 +1036,7 @@ In ELF32 **(Beta)** relocations additional care must be taken when relocating an
R_<CLS>_TLSIE_ADR_GOTTPREL_PAGE21,
R_<CLS>_TLSDESC_ADR_PAGE21

Relocations using the ``GDAT(S)`` operation must have a zero addend. Previous versions of this document included the addend ``A`` in ``GDAT(S + A)`` resulting in a GOT entry for ``S + A``. With a zero addend ``GDAT(S + 0)`` is equivalent to ``GDAT(S)`` and ``GDAT(S) + 0``.

Static miscellaneous relocations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1231,19 +1241,19 @@ The following tables record single instruction relocations and relocations that
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| ELF64 Code | ELF32 Code | Name | Operation | Comment |
+============+============+================================+===================+======================================================================+
| 300 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G0 | G(GDAT(S+A)) -GOT | Set a MOV[NZ] immediate field to bits [15:0] of X (see notes below) |
| 300 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G0 | G(GDAT(S)) -GOT | Set a MOV[NZ] immediate field to bits [15:0] of X (see notes below) |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 301 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G0\_NC | G(GDAT(S+A)) -GOT | Set a MOVK immediate field to bits [15:0] of X. No overflow check |
| 301 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G0\_NC | G(GDAT(S)) -GOT | Set a MOVK immediate field to bits [15:0] of X. No overflow check |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 302 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G1 | G(GDAT(S+A)) -GOT | Set a MOV[NZ] immediate value to bits [31:16] of X (see notes below) |
| 302 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G1 | G(GDAT(S)) -GOT | Set a MOV[NZ] immediate value to bits [31:16] of X (see notes below) |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 303 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G1\_NC | G(GDAT(S+A)) -GOT | Set a MOVK immediate value to bits [31:16] of X. No overflow check |
| 303 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G1\_NC | G(GDAT(S)) -GOT | Set a MOVK immediate value to bits [31:16] of X. No overflow check |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 304 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G2 | G(GDAT(S+A)) -GOT | Set a MOV[NZ] immediate value to bits [47:32] of X (see notes below) |
| 304 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G2 | G(GDAT(S)) -GOT | Set a MOV[NZ] immediate value to bits [47:32] of X (see notes below) |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 305 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G2\_NC | G(GDAT(S+A)) -GOT | Set a MOVK immediate value to bits [47:32] of X. No overflow check |
| 305 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G2\_NC | G(GDAT(S)) -GOT | Set a MOVK immediate value to bits [47:32] of X. No overflow check |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+
| 306 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G3 | G(GDAT(S+A)) -GOT | Set a MOV[NZ] immediate value to bits [63:48] of X (see notes below) |
| 306 | \- | R\_<CLS>\_MOVW\_GOTOFF\_G3 | G(GDAT(S)) -GOT | Set a MOV[NZ] immediate value to bits [63:48] of X (see notes below) |
+------------+------------+--------------------------------+-------------------+----------------------------------------------------------------------+

.. note::
Expand All @@ -1265,7 +1275,7 @@ The following tables record single instruction relocations and relocations that
| 308 | \- | R\_<CLS>\_GOTREL32 | S+A-GOT | Write bits [31:0] of X at byte-aligned place P. This represents a 32-bit offset relative to GOT, treated as signed; |
| | | | | Check that -2\ :sup:`31` <= X < 2\ :sup:`31`. |
+------------+------------+----------------------+------------------+-------------------------------------------------------------------------------------------------------------------------+
| 315 | \- | R\_<CLS>\_GOTPCREL32 | G(GDAT(S+A))- P | Write bits [31:0] of X at byte-aligned place P. This represents a 32-bit offset relative to GOT entry for an address, |
| 315 | \- | R\_<CLS>\_GOTPCREL32 | G(GDAT(S))- P | Write bits [31:0] of X at byte-aligned place P. This represents a 32-bit offset relative to GOT entry for an address, |
| | | | | treated as signed; Check that -2\ :sup:`31` <= X < 2\ :sup:`31`. |
+------------+------------+----------------------+------------------+-------------------------------------------------------------------------------------------------------------------------+

Expand All @@ -1278,19 +1288,19 @@ The following tables record single instruction relocations and relocations that
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| ELF64 Code | ELF32 Code | Name | Operation | Comment |
+=============+============+===============================+============================+======================================================================================================+
| 309 | 25 | R\_<CLS>\_GOT\_LD\_PREL19 | G(GDAT(S+A))- P | Set a load-literal immediate field to bits [20:2] of X; check –2\ :sup:`20` <= X < 2\ :sup:`20` |
| 309 | 25 | R\_<CLS>\_GOT\_LD\_PREL19 | G(GDAT(S))- P | Set a load-literal immediate field to bits [20:2] of X; check –2\ :sup:`20` <= X < 2\ :sup:`20` |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| 310 | \- | R\_<CLS>\_LD64\_GOTOFF\_LO15 | G(GDAT(S+A))- GOT | Set a LD/ST immediate field to bits [14:3] of X; check that 0 <= X < 2\ :sup:`15`, X&7 = 0 |
| 310 | \- | R\_<CLS>\_LD64\_GOTOFF\_LO15 | G(GDAT(S))- GOT | Set a LD/ST immediate field to bits [14:3] of X; check that 0 <= X < 2\ :sup:`15`, X&7 = 0 |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| 311 | 26 | R\_<CLS>\_ADR\_GOT\_PAGE | Page(G(GDAT(S+A)))-Page(P) | Set the immediate value of an ADRP to bits [32:12] of X; check that –2\ :sup:`32` <= X < 2\ :sup:`32`|
| 311 | 26 | R\_<CLS>\_ADR\_GOT\_PAGE | Page(G(GDAT(S)))-Page(P) | Set the immediate value of an ADRP to bits [32:12] of X; check that –2\ :sup:`32` <= X < 2\ :sup:`32`|
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| 312 | \- | R\_<CLS>\_LD64\_GOT\_LO12\_NC | G(GDAT(S+A)) | Set the LD/ST immediate field to bits [11:3] of X. No overflow check; check that X&7 = 0 |
| 312 | \- | R\_<CLS>\_LD64\_GOT\_LO12\_NC | G(GDAT(S)) | Set the LD/ST immediate field to bits [11:3] of X. No overflow check; check that X&7 = 0 |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| \- | 27 | R\_<CLS>\_LD32\_GOT\_LO12\_NC | G(GDAT(S+A)) | Set the LD/ST immediate field to bits [11:2] of X. No overflow check; check that X&3 = 0 |
| \- | 27 | R\_<CLS>\_LD32\_GOT\_LO12\_NC | G(GDAT(S)) | Set the LD/ST immediate field to bits [11:2] of X. No overflow check; check that X&3 = 0 |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| 313 | \- | R\_<CLS>\_LD64\_GOTPAGE\_LO15 | G(GDAT(S+A))-Page(GOT) | Set the LD/ST immediate field to bits [14:3] of X; check that 0 <= X < 2\ :sup:`15`, X&7 = 0 |
| 313 | \- | R\_<CLS>\_LD64\_GOTPAGE\_LO15 | G(GDAT(S))-Page(GOT) | Set the LD/ST immediate field to bits [14:3] of X; check that 0 <= X < 2\ :sup:`15`, X&7 = 0 |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+
| \- | 28 | R\_<CLS>\_LD32\_GOTPAGE\_LO14 | G(GDAT(S+A))-Page(GOT) | Set the LD/ST immediate field to bits [13:2] of X; check that 0 <= X < 2\ :sup:`14`, X&3 = 0 |
| \- | 28 | R\_<CLS>\_LD32\_GOTPAGE\_LO14 | G(GDAT(S))-Page(GOT) | Set the LD/ST immediate field to bits [13:2] of X; check that 0 <= X < 2\ :sup:`14`, X&3 = 0 |
+-------------+------------+-------------------------------+----------------------------+------------------------------------------------------------------------------------------------------+


Expand Down Expand Up @@ -1859,27 +1869,27 @@ At this time this ABI specifies no generic platform architecture compatibility d
Program Property
----------------

The information on Program Property has been moved to [SYSVABI64_].
The information on Program Property has moved to [SYSVABI64_].

Program Loading
---------------

The information on program loading has been moved to [SYSVABI64_].
The information on program loading has moved to [SYSVABI64_].

Dynamic Linking
---------------

The information on Dynamic Linking has been moved to [SYSVABI64_].
The information on Dynamic Linking has moved to [SYSVABI64_].

Dynamic Section
---------------

The information on the Dynamic Section has been moved to [SYSVABI64_].
The information on the Dynamic Section has moved to [SYSVABI64_].

Custom PLTs
^^^^^^^^^^^^

The information on custom PLTs has been moved to [SYSVABI64_].
The information on custom PLTs has moved to [SYSVABI64_].

.. raw:: pdf
Expand Down
Loading

0 comments on commit c87b0b1

Please sign in to comment.