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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 21:10:32 PST 2020


MaskRay created this revision.
MaskRay added reviewers: mrutland, nickdesaulniers, nsz, ostannard.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.

For -fpatchable-function-entry=N,0 -mbranch-protection=bti, after
9a24488cb67a90f889529987275c5e411ce01dda <https://reviews.llvm.org/rG9a24488cb67a90f889529987275c5e411ce01dda>, we place the NOP sled after
the initial BTI.

  .Lfunc_begin0:
  bti c
  nop
  nop
  
  .section __patchable_function_entries,"awo", at 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", at 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 token 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73680

Files:
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73680.241344.patch
Type: text/x-patch
Size: 5111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200130/1500b70f/attachment.bin>


More information about the llvm-commits mailing list