aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-04-24 17:36:02 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2020-05-14 13:16:29 +0100
commit9a1b74d49e2e25b29675fac4322bb7ba6cec5894 (patch)
tree8e954596def3df9c1eba8d860aed105fee156d1a
parentf6e42cdee5de2b3441afc88c8888c1166bdffe57 (diff)
aarch64: don't emit bti j after NOTE_INSN_DELETED_LABEL [PR94748]
It was previously discussed that indirect branches cannot go to NOTE_INSN_DELETED_LABEL so inserting a landing pad is unnecessary. See https://gcc.gnu.org/pipermail/gcc-patches/2019-May/522625.html Before the patch a bti j was inserted after the label in __attribute__((target("branch-protection=bti"))) int foo (void) { label: return 0; } This is not necessary and weakens the security protection. gcc/ChangeLog: Backport from mainline. 2020-04-30 Szabolcs Nagy <szabolcs.nagy@arm.com> PR target/94748 * config/aarch64/aarch64-bti-insert.c (rest_of_insert_bti): Remove the check for NOTE_INSN_DELETED_LABEL. gcc/testsuite/ChangeLog: Backport from mainline. 2020-04-30 Szabolcs Nagy <szabolcs.nagy@arm.com> PR target/94748 * gcc.target/aarch64/pr94748.c: New test.
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/aarch64/aarch64-bti-insert.c8
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.target/aarch64/pr94748.c10
4 files changed, 29 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1b814c7308b..80a48f8341c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,15 @@
2020-05-14 Szabolcs Nagy <szabolcs.nagy@arm.com>
Backport from mainline.
+ 2020-04-30 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ PR target/94748
+ * config/aarch64/aarch64-bti-insert.c (rest_of_insert_bti): Remove
+ the check for NOTE_INSN_DELETED_LABEL.
+
+2020-05-14 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ Backport from mainline.
2020-04-23 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/94697
diff --git a/gcc/config/aarch64/aarch64-bti-insert.c b/gcc/config/aarch64/aarch64-bti-insert.c
index 9e0fc168435..7da89074ce0 100644
--- a/gcc/config/aarch64/aarch64-bti-insert.c
+++ b/gcc/config/aarch64/aarch64-bti-insert.c
@@ -137,14 +137,10 @@ rest_of_insert_bti (void)
insn = NEXT_INSN (insn))
{
/* If a label is marked to be preserved or can be a non-local goto
- target, it must be protected with a BTI J. The same applies to
- NOTE_INSN_DELETED_LABEL since they are basically labels that might
- be referenced via variables or constant pool. */
- if ((LABEL_P (insn)
+ target, it must be protected with a BTI J. */
+ if (LABEL_P (insn)
&& (LABEL_PRESERVE_P (insn)
|| bb->flags & BB_NON_LOCAL_GOTO_TARGET))
- || (NOTE_P (insn)
- && NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))
{
bti_insn = gen_bti_j ();
emit_insn_after (bti_insn, insn);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a642d0f9a19..b69958e23d0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,14 @@
2020-05-14 Szabolcs Nagy <szabolcs.nagy@arm.com>
Backport from mainline.
+ 2020-04-30 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ PR target/94748
+ * gcc.target/aarch64/pr94748.c: New test.
+
+2020-05-14 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ Backport from mainline.
2020-04-27 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR target/94515
diff --git a/gcc/testsuite/gcc.target/aarch64/pr94748.c b/gcc/testsuite/gcc.target/aarch64/pr94748.c
new file mode 100644
index 00000000000..2a2850d2fac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr94748.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+__attribute__ ((target("branch-protection=bti")))
+int foo ()
+{
+label:
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not {hint (36|38) // bti (j|jc)} } } */