arm64: Add Armv8.5-A BTI support to assembly files.

Change-Id: Ic9c2d252829a39b0331e436df16effe7d0607996
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3241142
Commit-Queue: Jonathan Wright <jonathan.wright@arm.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Salome Thirot 2021-11-30 10:38:31 +00:00 committed by Crashpad LUCI CQ
parent 3b8a7cf594
commit fe19de6e1d
5 changed files with 52 additions and 0 deletions

View File

@ -17,6 +17,7 @@
// that symbol to be in the dynamic symbol table.
#include "util/misc/elf_note_types.h"
#include "util/misc/arm64_bti_note.S"
// namespace crashpad {
// CrashpadInfo g_crashpad_info;

View File

@ -17,6 +17,7 @@
// that symbol to be in the dynamic symbol table.
#include "util/misc/elf_note_types.h"
#include "util/misc/arm64_bti_note.S"
// namespace crashpad {
// CrashpadInfo g_test_crashpad_info;

View File

@ -13,6 +13,7 @@
// limitations under the License.
#include "util/misc/elf_note_types.h"
#include "util/misc/arm64_bti_note.S"
#define NOTE_ALIGN 4
.section .note.crashpad.test,"a",%note

View File

@ -0,0 +1,46 @@
// Copyright 2021 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S
#define CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S
/* Support macros for the Armv8.5-A Branch Target Identification feature which
* requires emitting a .note.gnu.property section with the appropriate
* architecture-dependent feature bits set.
* Read more: "ELF for the Arm® 64-bit Architecture"
*/
#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1)
#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI
.pushsection .note.gnu.property, "a"
.balign 4
.long 0x4 /* size of field "GNU" */
.long 0x10 /* note descriptor size */
.long 0x5 /* type of note descriptor: NT_GNU_PROPERTY_TYPE_0 */
.asciz "GNU"
.long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 0x4
.long GNU_PROPERTY_AARCH64_BTI
.long 0x0
.popsection
#define CRASHPAD_AARCH64_VALID_JUMP_CALL_TARGET bti jc
#define CRASHPAD_AARCH64_VALID_CALL_TARGET bti c
#define CRASHPAD_AARCH64_VALID_JUMP_TARGET bti j
#undef GNU_PROPERTY_AARCH64_BTI
#else
#define CRASHPAD_AARCH64_VALID_JUMP_CALL_TARGET
#define CRASHPAD_AARCH64_VALID_CALL_TARGET
#define CRASHPAD_AARCH64_VALID_JUMP_TARGET
#endif
#endif /* CRASHPAD_UTIL_MISC_ARM64_BTI_NOTE_S */

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/misc/arm64_bti_note.S"
// namespace crashpad {
// void CaptureContext(ucontext_t* context);
// } // namespace crashpad
@ -38,6 +40,7 @@
CAPTURECONTEXT_SYMBOL:
CAPTURECONTEXT_SYMBOL2:
CRASHPAD_AARCH64_VALID_CALL_TARGET
#if defined(__i386__)