]> gcc.gnu.org Git - 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, 23 Apr 2020 15:14:28 +0000 (16:14 +0100)
commitf7e4641afba7c348a7e7c8655e537a953c416bb3
tree09c18d44d073ab39f6ad54c1cf417bd525aaf1fb
parent857d1fa3f0a04569382bab12829e5bfd3725ecbf
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.

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

PR target/94697
* gcc.target/aarch64/pr94697.c: New test.
gcc/ChangeLog
gcc/config/aarch64/aarch64-bti-insert.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/pr94697.c [new file with mode: 0644]
This page took 0.068832 seconds and 6 git commands to generate.