HomePhabricator

[AArch64] -fpatchable-function-entry=N,0: place patch label after BTI

Authored by MaskRay on Jan 29 2020, 6:00 PM.

Description

[AArch64] -fpatchable-function-entry=N,0: place patch label after BTI

Summary:
For -fpatchable-function-entry=N,0 -mbranch-protection=bti, after
9a24488cb67a90f889529987275c5e411ce01dda, we place the NOP sled after
the initial BTI.

.Lfunc_begin0:
bti c
nop
nop

.section __patchable_function_entries,"awo",@progbits,f,unique,0
.p2align 3
.xword .Lfunc_begin0

This patch adds a label after the initial BTI and changes the __patchable_function_entries entry to reference the label:

.Lfunc_begin0:
bti c
.Lpatch0:
nop
nop

.section __patchable_function_entries,"awo",@progbits,f,unique,0
.p2align 3
.xword .Lpatch0

This placement is compatible with the resolution in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424 .

A local linkage function whose address is not taken does not need a BTI.
Placing the patch label after BTI has the advantage that code does not
need to differentiate whether the function has an initial BTI.

Reviewers: mrutland, nickdesaulniers, nsz, ostannard

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73680

Details

Committed
MaskRayJan 30 2020, 11:11 AM
Differential Revision
D73680: [AArch64] -fpatchable-function-entry=N,0: place patch label after BTI
Parents
rGaf3e88495627: Speed up compilation of ASTImporter
Branches
Unknown
Tags
Unknown