Skip to content

Commit 21caf60

Browse files
committed
Add Tool Requirements for Generating Landing Pad Instructions
1 parent d0bba89 commit 21caf60

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

riscv-elf.adoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,7 @@ provided by the Zicfilp extension in the unlabeled scheme: Executables and
15281528
shared libraries with this bit set are required to generate PLTs in the
15291529
unlabeled landing pad PLT style, and all of the labels of lpad instructions are
15301530
set to 0, i.e. unlabeled.
1531+
See <<Tool Requirements for Generating Landing Pad Instruction>> for more details.
15311532

15321533
`GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS`: This bit indicates that all executable
15331534
sections are built to be compatible with the shadow stack mechanism provided by
@@ -1537,6 +1538,39 @@ or the `Zimop` extension. When the executable or shared library is compiled with
15371538
compressed instructions then loading it with this bit set requires the execution
15381539
environment to provide the `Zicfiss` extension or the `Zcmop` extensions.
15391540

1541+
=== Tool Requirements for Generating Landing Pad Instructions
1542+
1543+
For an executable or shared library to set the GNU property
1544+
`GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED`, every indirect branch targeting
1545+
a location guarded by landing pads must point to a landing pad (`lpad`)
1546+
instruction with a compatible label value. Indirect branches may originate from:
1547+
1548+
* Relocatable object producers, such as a compiler or assembler.
1549+
1550+
* Static linkers when generating PLT entries.
1551+
1552+
* Other executables and shared libraries via calls through PLT entries or
1553+
function pointers.
1554+
1555+
It is desirable to minimize the number of landing pad instructions to limit the
1556+
number of indirect branch destinations within the program. The following tool
1557+
requirements determine which tool is responsible for inserting landing pad
1558+
instructions, allowing tools to omit landing pad instructions if it can be
1559+
proven that there are no indirect branches targeting the location.
1560+
1561+
A relocatable object producer is required to insert a landing pad instruction at
1562+
the target of an indirect branch originating from within the same relocatable
1563+
object.
1564+
1565+
A relocatable object producer must insert a landing pad instruction at any
1566+
location whose address escapes the relocatable object. This includes all symbols
1567+
that can be exported into the dynamic symbol table by a static linker.
1568+
1569+
A static linker is required to generate PLT entries with appropriate landing pad
1570+
instructions. During linker relaxation, a static linker may remove unnecessary
1571+
landing pad instructions if it can prove that there are no indirect branches
1572+
targeting the corresponding location.
1573+
15401574
=== Mapping Symbol
15411575

15421576
The section can have a mixture of code and data or code with different ISAs.

0 commit comments

Comments
 (0)