aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSudakshina Das <sudi.das@arm.com>2019-04-23 15:51:25 +0000
committerSudakshina Das <sudi@gcc.gnu.org>2019-04-23 15:51:25 +0000
commit32efff9f947137bb6f6bf47a846e3bf8a162170a (patch)
tree2e71f2ea88b9a17d4c37acd54774bc6359e35af6
parentc7bfed18df8a3f85eb8acd15f860c3e828cd61d0 (diff)
downloadgcc-32efff9f947137bb6f6bf47a846e3bf8a162170a.zip
gcc-32efff9f947137bb6f6bf47a846e3bf8a162170a.tar.gz
gcc-32efff9f947137bb6f6bf47a846e3bf8a162170a.tar.bz2
[GCC, AARCH64] Add GNU note section with BTI and PAC.
This patch adds the GNU NOTE section to the BTI and/or PAC enabled objects for linux targets. The patches for needed for these in binutils are already approved and committed. https://sourceware.org/ml/binutils/2019-03/msg00072.html *** gcc/ChangeLog *** 2018-04-23 Sudakshina Das <sudi.das@arm.com> * config/aarch64/aarch64-linux.h (TARGET_ASM_FILE_END): Define for AArch64. (aarch64_file_end_indicate_exec_stack): Add gnu note section. gcc/testsuite/ChangeLog: 2018-04-23 Sudakshina Das <sudi.das@arm.com> * gcc.target/aarch64/bti-1.c: Add scan directive for gnu note section for linux targets. * gcc.target/aarch64/va_arg_1.c: Update scan directive to not clash with GNU note section. From-SVN: r270515
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/aarch64/aarch64-linux.h2
-rw-r--r--gcc/config/aarch64/aarch64.c51
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/aarch64/bti-1.c1
-rw-r--r--gcc/testsuite/gcc.target/aarch64/va_arg_1.c2
6 files changed, 68 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5ea2fa0..2c1cc37 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-23 Sudakshina Das <sudi.das@arm.com>
+
+ * config/aarch64/aarch64-linux.h (TARGET_ASM_FILE_END): Define for
+ AArch64.
+ (aarch64_file_end_indicate_exec_stack): Add gnu note section.
+
+
2019-04-23 Roman Zhuykov <zhroma@ispras.ru>
PR rtl-optimization/87979
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 9d0292d..5e8b34d 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -83,7 +83,7 @@
#define GNU_USER_TARGET_D_CRITSEC_SIZE 48
-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+#define TARGET_ASM_FILE_END aarch64_file_end_indicate_exec_stack
/* Uninitialized common symbols in non-PIE executables, even with
strong definitions in dependent shared libraries, will resolve
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 10b0bd2..1425943 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -18772,6 +18772,57 @@ aarch64_stack_protect_guard (void)
return NULL_TREE;
}
+/* Implement TARGET_ASM_FILE_END for AArch64. This adds the AArch64 GNU NOTE
+ section at the end if needed. */
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
+void
+aarch64_file_end_indicate_exec_stack ()
+{
+ file_end_indicate_exec_stack ();
+
+ unsigned feature_1_and = 0;
+ if (aarch64_bti_enabled ())
+ feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
+
+ if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE)
+ feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
+
+ if (feature_1_and)
+ {
+ /* Generate .note.gnu.property section. */
+ switch_to_section (get_section (".note.gnu.property",
+ SECTION_NOTYPE, NULL));
+
+ /* PT_NOTE header: namesz, descsz, type.
+ namesz = 4 ("GNU\0")
+ descsz = 16 (Size of the program property array)
+ [(12 + padding) * Number of array elements]
+ type = 5 (NT_GNU_PROPERTY_TYPE_0). */
+ assemble_align (POINTER_SIZE);
+ assemble_integer (GEN_INT (4), 4, 32, 1);
+ assemble_integer (GEN_INT (ROUND_UP (12, POINTER_BYTES)), 4, 32, 1);
+ assemble_integer (GEN_INT (5), 4, 32, 1);
+
+ /* PT_NOTE name. */
+ assemble_string ("GNU", 4);
+
+ /* PT_NOTE contents for NT_GNU_PROPERTY_TYPE_0:
+ type = GNU_PROPERTY_AARCH64_FEATURE_1_AND
+ datasz = 4
+ data = feature_1_and. */
+ assemble_integer (GEN_INT (GNU_PROPERTY_AARCH64_FEATURE_1_AND), 4, 32, 1);
+ assemble_integer (GEN_INT (4), 4, 32, 1);
+ assemble_integer (GEN_INT (feature_1_and), 4, 32, 1);
+
+ /* Pad the size of the note to the required alignment. */
+ assemble_align (POINTER_SIZE);
+ }
+}
+#undef GNU_PROPERTY_AARCH64_FEATURE_1_PAC
+#undef GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+#undef GNU_PROPERTY_AARCH64_FEATURE_1_AND
/* Target-specific selftests. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 81d6f26..76e1a8e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-04-23 Sudakshina Das <sudi.das@arm.com>
+
+ * gcc.target/aarch64/bti-1.c: Add scan directive for gnu note section
+ for linux targets.
+ * gcc.target/aarch64/va_arg_1.c: Update scan directive to not clash
+ with GNU note section.
+
2019-04-23 Jeff Law <law@redhat.com>
* lib/target-supports.exp
diff --git a/gcc/testsuite/gcc.target/aarch64/bti-1.c b/gcc/testsuite/gcc.target/aarch64/bti-1.c
index a8c6041..5a556b0 100644
--- a/gcc/testsuite/gcc.target/aarch64/bti-1.c
+++ b/gcc/testsuite/gcc.target/aarch64/bti-1.c
@@ -61,3 +61,4 @@ lab2:
}
/* { dg-final { scan-assembler-times "hint\t34" 1 } } */
/* { dg-final { scan-assembler-times "hint\t36" 12 } } */
+/* { dg-final { scan-assembler ".note.gnu.property" { target *-*-linux* } } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/va_arg_1.c b/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
index e8e3cda..5bcb5f3 100644
--- a/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
@@ -4,7 +4,7 @@
int
f (int a, ...)
{
- /* { dg-final { scan-assembler-not "str" } } */
+ /* { dg-final { scan-assembler-not "str\t" } } */
return a;
}