]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: ensure bti c is emitted at function start [PR94697]
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 17 Apr 2020 15:54:12 +0000 (16:54 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 14 May 2020 12:11:22 +0000 (13:11 +0100)
commitf6e42cdee5de2b3441afc88c8888c1166bdffe57
tree2450c1f36c445d441e6d12310aae9560987745c2
parent95833c34424f340a7e465ee38b6a41369bc7c90b
aarch64: ensure bti c is emitted at function start [PR94697]

The bti pass currently first emits bti c at function start
if there is no paciasp (which also acts as indirect call
landing pad), then bti j is emitted at jump labels, however
if there is a label right before paciasp then the function
start can end up like

  foo:
  label:
    bti j
    paciasp
    ...

This patch is a minimal fix that just moves the bti c handling
after the bti j handling so we end up with

  foo:
    bti c
  label:
    bti j
    paciasp
    ...

This could be improved by emitting bti jc in this case, or by
detecting that the label is not in fact an indirect jump target
and then this situation would be much less common.

Needs to be backported to gcc-9 branch.

Backported without the testcase because of missing infrastructure
for check-function-bodies.

gcc/ChangeLog:

Backport from mainline.
2020-04-23  Szabolcs Nagy  <szabolcs.nagy@arm.com>

PR target/94697
* config/aarch64/aarch64-bti-insert.c (rest_of_insert_bti): Swap
bti c and bti j handling.
gcc/ChangeLog
gcc/config/aarch64/aarch64-bti-insert.c