-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sysvabi64] Document requirements for tools wrt BTI #282
Changes from 3 commits
3008640
c3250a4
9a2e7c8
e69c2ac
256815a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1646,9 +1646,8 @@ The following bits are defined for GNU_PROPERTY_AARCH64_FEATURE_1_AND: | |
+-----------------------------------------+------------+ | ||
|
||
``GNU_PROPERTY_AARCH64_FEATURE_1_BTI`` This indicates that all executable | ||
sections are compatible with Branch Target Identification mechanism. An | ||
executable or shared object with this bit set is required to generate | ||
`Custom PLTs`_ with BTI instruction. | ||
sections are compatible with Branch Target Identification mechanism. See | ||
`Tool requirements for generating BTI instructions`_. | ||
|
||
``GNU_PROPERTY_AARCH64_FEATURE_1_PAC`` This indicates that all | ||
executable sections have been protected with Return Address Signing. | ||
|
@@ -1671,6 +1670,65 @@ include: | |
* Any functions used by the program that manipulate the stack such as | ||
``setjmp`` and ``longjmp``, must be aware of GCS. | ||
|
||
Tool Requirements for generating BTI instructions | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
For an executable or shared library to set | ||
``GNU_PROPERTY_AARCH64_FEATURE_1_BTI`` every indirect branch to a | ||
location in a guarded page must target a BTI instruction that is | ||
compatible with the PSTATE.BTYPE value. Indirect branches can come | ||
from: | ||
|
||
* Relocatable object producers, such as a compiler or assembler. | ||
|
||
* Static linkers when generating PLT sequences or veneers. | ||
|
||
* Other executables and shared libraries via call from a PLT or a | ||
function pointer. | ||
|
||
It is desirable to minimize the number of BTI instructions to limit | ||
the number of indirect branch destinations in the program. The | ||
following tool requirements determine which tool has the | ||
responsibility of inserting the BTI instruction, permitting a tool to | ||
elide the BTI instuction when it can prove that there are no indirect | ||
calls to that location. | ||
|
||
A relocatable object producer is required to add a BTI instruction to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider putting each requirement in a list item. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK |
||
the destination of an indirect branch originating in the same | ||
relocatable object. | ||
|
||
A relocatable object producer is required to add a BTI instruction to | ||
a location when the address of that location is live and escapes out | ||
of the relocatable object. This includes the locations of all symbols | ||
that can be exported into the dynamic symbol table by a static linker. | ||
|
||
A static linker is required to generate `Custom PLTs`_ with BTI | ||
instructions. | ||
|
||
A static linker that uses indirect branches in veneers is required to | ||
generate a BTI compatible landing pad if the target of the indirect | ||
branch is defined within the same link unit and does not have a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please clarify why "if ... defined within the same link unit" is necessary? What happens in the case where the target is defined in another link unit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've gone with a more abstract escapes to an opaque entity. The original text refers to the boundary between the compiler/assembler and linker, but it can be more general than that. For example inline assembly that the compiler can't see into could indirect branch if the escaped address were on the input list. |
||
compatible BTI instruction at the destination of the veneer. A BTI | ||
compatible landing pad consists of a BTI instruction followed by a | ||
direct branch. For example: | ||
|
||
.. code-block:: asm | ||
|
||
// Linker generated veneer using indirect bracnh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "bracnh" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK |
||
adrp x16, fn | ||
add x16, :lo12: fn | ||
br x16 | ||
... | ||
// Linker generated BTI landing pad | ||
bti c | ||
b fn | ||
... | ||
// Destination of veneer without a BTI instruction. | ||
fn: | ||
// a non BTI instruction. | ||
|
||
A static linker is not required to insert BTI compatible landing pads | ||
for symbols with section index ``SHN_ABS``. | ||
|
||
Program Loading | ||
--------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "instuction"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK