Merge BoringSSL 'a905bbb': Consistently include BTI markers in every assembly file
This commit is contained in:
commit
00da1cb1f7
@ -110,10 +110,12 @@ include = [
|
||||
"examples/**/*.rs",
|
||||
"include/ring-core/aes.h",
|
||||
"include/ring-core/arm_arch.h",
|
||||
"include/ring-core/asm_base.h",
|
||||
"include/ring-core/base.h",
|
||||
"include/ring-core/check.h",
|
||||
"include/ring-core/mem.h",
|
||||
"include/ring-core/poly1305.h",
|
||||
"include/ring-core/target.h",
|
||||
"include/ring-core/type_check.h",
|
||||
"src/**/*.rs",
|
||||
"src/aead/poly1305_test.txt",
|
||||
|
@ -17,15 +17,9 @@
|
||||
* domain licensed but the standard ISC license is included above to keep
|
||||
* licensing simple. */
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#endif
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__)
|
||||
|
||||
#include "ring_core_generated/prefix_symbols_asm.h"
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__)
|
||||
|
||||
.fpu neon
|
||||
.text
|
||||
@ -2127,8 +2121,4 @@ mov sp,r12
|
||||
vpop {q4,q5,q6,q7}
|
||||
bx lr
|
||||
|
||||
#endif /* !OPENSSL_NO_ASM && __ARMEL__ && __ELF__ */
|
||||
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
#endif /* !OPENSSL_NO_ASM && OPENSSL_ARM && __ELF__ */
|
||||
|
@ -153,9 +153,9 @@ sub expand_line {
|
||||
|
||||
my ($arch_defines, $target_defines);
|
||||
if ($flavour =~ /32/) {
|
||||
$arch_defines = "defined(__ARMEL__)";
|
||||
$arch_defines = "defined(OPENSSL_ARM)";
|
||||
} elsif ($flavour =~ /64/) {
|
||||
$arch_defines = "defined(__AARCH64EL__)";
|
||||
$arch_defines = "defined(OPENSSL_AARCH64)";
|
||||
} else {
|
||||
die "unknown architecture: $flavour";
|
||||
}
|
||||
@ -177,18 +177,11 @@ print <<___;
|
||||
// This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
// source tree. Do not edit by hand.
|
||||
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && $arch_defines && $target_defines
|
||||
___
|
||||
|
||||
print "#include \"ring_core_generated/prefix_symbols_asm.h\"\n";
|
||||
|
||||
while(my $line=<>) {
|
||||
|
||||
if ($line =~ m/^\s*(#|@|\/\/)/) { print $line; next; }
|
||||
@ -258,10 +251,6 @@ while(my $line=<>) {
|
||||
|
||||
print <<___;
|
||||
#endif // !OPENSSL_NO_ASM && $arch_defines && $target_defines
|
||||
#if defined(__ELF__)
|
||||
// See https://www.airs.com/blog/archives/518.
|
||||
.section .note.GNU-stack,"",\%progbits
|
||||
#endif
|
||||
___
|
||||
|
||||
close STDOUT or die "error closing STDOUT: $!";
|
||||
|
@ -1520,14 +1520,9 @@ if ($gas) {
|
||||
die "unknown target: $flavour";
|
||||
}
|
||||
print <<___;
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#endif
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && $target
|
||||
#include "ring_core_generated/prefix_symbols_asm.h"
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && $target
|
||||
___
|
||||
}
|
||||
|
||||
@ -1623,13 +1618,7 @@ print "\n$current_segment\tENDS\n" if ($current_segment && $masm);
|
||||
if ($masm) {
|
||||
print "END\n";
|
||||
} elsif ($gas) {
|
||||
print <<___;
|
||||
#endif
|
||||
#if defined(__ELF__)
|
||||
// See https://www.airs.com/blog/archives/518.
|
||||
.section .note.GNU-stack,"",\%progbits
|
||||
#endif
|
||||
___
|
||||
print "#endif\n";
|
||||
} elsif ($nasm) {
|
||||
print <<___;
|
||||
\%else
|
||||
|
@ -305,22 +305,13 @@ ___
|
||||
}
|
||||
|
||||
print <<___;
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#endif
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && $target
|
||||
#include "ring_core_generated/prefix_symbols_asm.h"
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && $target
|
||||
___
|
||||
print @out;
|
||||
print <<___;
|
||||
#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && $target
|
||||
#if defined(__ELF__)
|
||||
// See https://www.airs.com/blog/archives/518.
|
||||
.section .note.GNU-stack,"",\%progbits
|
||||
#endif
|
||||
#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && $target
|
||||
___
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#endif
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if defined(__ARMEL__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__)
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__)
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wlanguage-extension-token"
|
||||
|
||||
#include "ring_core_generated/prefix_symbols_asm.h"
|
||||
|
||||
# This implementation was taken from the public domain, neon2 version in
|
||||
# SUPERCOP by D. J. Bernstein and Peter Schwabe.
|
||||
|
||||
@ -2022,8 +2016,4 @@ vst1.8 d4,[r0,: 64]
|
||||
add sp,sp,#0
|
||||
bx lr
|
||||
|
||||
#endif /* __ARMEL__ && !OPENSSL_NO_ASM && __ELF__ */
|
||||
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
#endif /* !OPENSSL_NO_ASM && OPENSSL_ARM && __ELF__ */
|
||||
|
@ -53,12 +53,13 @@
|
||||
#ifndef OPENSSL_HEADER_ARM_ARCH_H
|
||||
#define OPENSSL_HEADER_ARM_ARCH_H
|
||||
|
||||
#include <ring-core/target.h>
|
||||
|
||||
// arm_arch.h contains symbols used by ARM assembly, and the C code that calls
|
||||
// it. It is included as a public header to simplify the build, but is not
|
||||
// intended for external use.
|
||||
|
||||
#if defined(__ARMEL__) || defined(_M_ARM) || defined(__AARCH64EL__) || \
|
||||
defined(_M_ARM64)
|
||||
#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
|
||||
|
||||
// ARMV7_NEON is true when a NEON unit is present in the current CPU.
|
||||
#define ARMV7_NEON (1 << 0)
|
||||
@ -91,124 +92,8 @@
|
||||
// will be included.
|
||||
#define __ARM_MAX_ARCH__ 8
|
||||
|
||||
// Support macros for
|
||||
// - Armv8.3-A Pointer Authentication and
|
||||
// - Armv8.5-A Branch Target Identification
|
||||
// features which require emitting a .note.gnu.property section with the
|
||||
// appropriate architecture-dependent feature bits set.
|
||||
//
|
||||
// |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to
|
||||
// PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be
|
||||
// used immediately before saving the LR register (x30) to the stack.
|
||||
// |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring
|
||||
// it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone
|
||||
// with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also
|
||||
// have the same value at the two points. For example:
|
||||
//
|
||||
// .global f
|
||||
// f:
|
||||
// AARCH64_SIGN_LINK_REGISTER
|
||||
// stp x29, x30, [sp, #-96]!
|
||||
// mov x29, sp
|
||||
// ...
|
||||
// ldp x29, x30, [sp], #96
|
||||
// AARCH64_VALIDATE_LINK_REGISTER
|
||||
// ret
|
||||
//
|
||||
// |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or
|
||||
// |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an
|
||||
// indirect call target. In particular, all symbols exported from a file must
|
||||
// begin with one of these macros. For example, a leaf function that does not
|
||||
// save LR can instead use |AARCH64_VALID_CALL_TARGET|:
|
||||
//
|
||||
// .globl return_zero
|
||||
// return_zero:
|
||||
// AARCH64_VALID_CALL_TARGET
|
||||
// mov x0, #0
|
||||
// ret
|
||||
//
|
||||
// A non-leaf function which does not immediately save LR may need both macros
|
||||
// because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function
|
||||
// may jump to an alternate implementation before setting up the stack:
|
||||
//
|
||||
// .globl with_early_jump
|
||||
// with_early_jump:
|
||||
// AARCH64_VALID_CALL_TARGET
|
||||
// cmp x0, #128
|
||||
// b.lt .Lwith_early_jump_128
|
||||
// AARCH64_SIGN_LINK_REGISTER
|
||||
// stp x29, x30, [sp, #-96]!
|
||||
// mov x29, sp
|
||||
// ...
|
||||
// ldp x29, x30, [sp], #96
|
||||
// AARCH64_VALIDATE_LINK_REGISTER
|
||||
// ret
|
||||
//
|
||||
// .Lwith_early_jump_128:
|
||||
// ...
|
||||
// ret
|
||||
//
|
||||
// These annotations are only required with indirect calls. Private symbols that
|
||||
// are only the target of direct calls do not require annotations. Also note
|
||||
// that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not
|
||||
// indirect jumps (BR). Indirect jumps in assembly are currently not supported
|
||||
// and would require a macro for BTI 'j'.
|
||||
//
|
||||
// Although not necessary, it is safe to use these macros in 32-bit ARM
|
||||
// assembly. This may be used to simplify dual 32-bit and 64-bit files.
|
||||
//
|
||||
// References:
|
||||
// - "ELF for the Arm® 64-bit Architecture"
|
||||
// https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst
|
||||
// - "Providing protection for complex software"
|
||||
// https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
|
||||
|
||||
#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
|
||||
#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification
|
||||
#define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c'
|
||||
#else
|
||||
#define GNU_PROPERTY_AARCH64_BTI 0 // No Branch Target Identification
|
||||
#define AARCH64_VALID_CALL_TARGET
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
||||
(__ARM_FEATURE_PAC_DEFAULT & 1) == 1 // Signed with A-key
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
||||
(1 << 1) // Has Pointer Authentication
|
||||
#define AARCH64_SIGN_LINK_REGISTER hint #25 // PACIASP
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER hint #29 // AUTIASP
|
||||
#elif defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
||||
(__ARM_FEATURE_PAC_DEFAULT & 2) == 2 // Signed with B-key
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
||||
(1 << 1) // Has Pointer Authentication
|
||||
#define AARCH64_SIGN_LINK_REGISTER hint #27 // PACIBSP
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER hint #31 // AUTIBSP
|
||||
#else
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 // No Pointer Authentication
|
||||
#if GNU_PROPERTY_AARCH64_BTI != 0
|
||||
#define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET
|
||||
#else
|
||||
#define AARCH64_SIGN_LINK_REGISTER
|
||||
#endif
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER
|
||||
#endif
|
||||
|
||||
#if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0
|
||||
.pushsection .note.gnu.property, "a";
|
||||
.balign 8;
|
||||
.long 4;
|
||||
.long 0x10;
|
||||
.long 0x5;
|
||||
.asciz "GNU";
|
||||
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
|
||||
.long 4;
|
||||
.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI);
|
||||
.long 0;
|
||||
.popsection;
|
||||
#endif
|
||||
|
||||
#endif // __ASSEMBLER__
|
||||
|
||||
#endif // __ARMEL__ || _M_ARM || __AARCH64EL__ || _M_ARM64
|
||||
#endif // ARM || AARCH64
|
||||
|
||||
#endif // OPENSSL_HEADER_ARM_ARCH_H
|
||||
|
186
include/ring-core/asm_base.h
Normal file
186
include/ring-core/asm_base.h
Normal file
@ -0,0 +1,186 @@
|
||||
/* Copyright (c) 2023, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_ASM_BASE_H
|
||||
#define OPENSSL_HEADER_ASM_BASE_H
|
||||
|
||||
#include <ring-core/target.h>
|
||||
|
||||
|
||||
// This header contains symbols and common sections used by assembly files. It
|
||||
// is included as a public header to simplify the build, but is not intended for
|
||||
// external use.
|
||||
//
|
||||
// Every assembly file must include this header. Some linker features require
|
||||
// all object files to be tagged with some section metadata. This header file,
|
||||
// when included in assembly, adds that metadata. It also makes defines like
|
||||
// |OPENSSL_X86_64| available and includes the prefixing macros.
|
||||
//
|
||||
// Including this header in an assembly file imples:
|
||||
//
|
||||
// - The file does not require an executable stack.
|
||||
//
|
||||
// - The file, on aarch64, uses the macros defined below to be compatible with
|
||||
// BTI and PAC.
|
||||
|
||||
#if defined(__ASSEMBLER__)
|
||||
|
||||
#include <ring_core_generated/prefix_symbols_asm.h>
|
||||
|
||||
#if defined(__ELF__)
|
||||
// Every ELF object file, even empty ones, should disable executable stacks. See
|
||||
// https://www.airs.com/blog/archives/518.
|
||||
.pushsection .note.GNU-stack, "", %progbits
|
||||
.popsection
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
|
||||
|
||||
// We require the ARM assembler provide |__ARM_ARCH| from Arm C Language
|
||||
// Extensions (ACLE). This is supported in GCC 4.8+ and Clang 3.2+. MSVC does
|
||||
// not implement ACLE, but we require Clang's assembler on Windows.
|
||||
#if !defined(__ARM_ARCH)
|
||||
#error "ARM assembler must define __ARM_ARCH"
|
||||
#endif
|
||||
|
||||
// __ARM_ARCH__ is used by OpenSSL assembly to determine the minimum target ARM
|
||||
// version.
|
||||
//
|
||||
// TODO(davidben): Switch the assembly to use |__ARM_ARCH| directly.
|
||||
#define __ARM_ARCH__ __ARM_ARCH
|
||||
|
||||
// Even when building for 32-bit ARM, support for aarch64 crypto instructions
|
||||
// will be included.
|
||||
#define __ARM_MAX_ARCH__ 8
|
||||
|
||||
// Support macros for
|
||||
// - Armv8.3-A Pointer Authentication and
|
||||
// - Armv8.5-A Branch Target Identification
|
||||
// features which require emitting a .note.gnu.property section with the
|
||||
// appropriate architecture-dependent feature bits set.
|
||||
//
|
||||
// |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to
|
||||
// PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be
|
||||
// used immediately before saving the LR register (x30) to the stack.
|
||||
// |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring
|
||||
// it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone
|
||||
// with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also
|
||||
// have the same value at the two points. For example:
|
||||
//
|
||||
// .global f
|
||||
// f:
|
||||
// AARCH64_SIGN_LINK_REGISTER
|
||||
// stp x29, x30, [sp, #-96]!
|
||||
// mov x29, sp
|
||||
// ...
|
||||
// ldp x29, x30, [sp], #96
|
||||
// AARCH64_VALIDATE_LINK_REGISTER
|
||||
// ret
|
||||
//
|
||||
// |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or
|
||||
// |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an
|
||||
// indirect call target. In particular, all symbols exported from a file must
|
||||
// begin with one of these macros. For example, a leaf function that does not
|
||||
// save LR can instead use |AARCH64_VALID_CALL_TARGET|:
|
||||
//
|
||||
// .globl return_zero
|
||||
// return_zero:
|
||||
// AARCH64_VALID_CALL_TARGET
|
||||
// mov x0, #0
|
||||
// ret
|
||||
//
|
||||
// A non-leaf function which does not immediately save LR may need both macros
|
||||
// because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function
|
||||
// may jump to an alternate implementation before setting up the stack:
|
||||
//
|
||||
// .globl with_early_jump
|
||||
// with_early_jump:
|
||||
// AARCH64_VALID_CALL_TARGET
|
||||
// cmp x0, #128
|
||||
// b.lt .Lwith_early_jump_128
|
||||
// AARCH64_SIGN_LINK_REGISTER
|
||||
// stp x29, x30, [sp, #-96]!
|
||||
// mov x29, sp
|
||||
// ...
|
||||
// ldp x29, x30, [sp], #96
|
||||
// AARCH64_VALIDATE_LINK_REGISTER
|
||||
// ret
|
||||
//
|
||||
// .Lwith_early_jump_128:
|
||||
// ...
|
||||
// ret
|
||||
//
|
||||
// These annotations are only required with indirect calls. Private symbols that
|
||||
// are only the target of direct calls do not require annotations. Also note
|
||||
// that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not
|
||||
// indirect jumps (BR). Indirect jumps in assembly are currently not supported
|
||||
// and would require a macro for BTI 'j'.
|
||||
//
|
||||
// Although not necessary, it is safe to use these macros in 32-bit ARM
|
||||
// assembly. This may be used to simplify dual 32-bit and 64-bit files.
|
||||
//
|
||||
// References:
|
||||
// - "ELF for the Arm® 64-bit Architecture"
|
||||
// https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst
|
||||
// - "Providing protection for complex software"
|
||||
// https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
|
||||
|
||||
#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
|
||||
#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification
|
||||
#define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c'
|
||||
#else
|
||||
#define GNU_PROPERTY_AARCH64_BTI 0 // No Branch Target Identification
|
||||
#define AARCH64_VALID_CALL_TARGET
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
||||
(__ARM_FEATURE_PAC_DEFAULT & 1) == 1 // Signed with A-key
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
||||
(1 << 1) // Has Pointer Authentication
|
||||
#define AARCH64_SIGN_LINK_REGISTER hint #25 // PACIASP
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER hint #29 // AUTIASP
|
||||
#elif defined(__ARM_FEATURE_PAC_DEFAULT) && \
|
||||
(__ARM_FEATURE_PAC_DEFAULT & 2) == 2 // Signed with B-key
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH \
|
||||
(1 << 1) // Has Pointer Authentication
|
||||
#define AARCH64_SIGN_LINK_REGISTER hint #27 // PACIBSP
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER hint #31 // AUTIBSP
|
||||
#else
|
||||
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 // No Pointer Authentication
|
||||
#if GNU_PROPERTY_AARCH64_BTI != 0
|
||||
#define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET
|
||||
#else
|
||||
#define AARCH64_SIGN_LINK_REGISTER
|
||||
#endif
|
||||
#define AARCH64_VALIDATE_LINK_REGISTER
|
||||
#endif
|
||||
|
||||
#if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0
|
||||
.pushsection .note.gnu.property, "a";
|
||||
.balign 8;
|
||||
.long 4;
|
||||
.long 0x10;
|
||||
.long 0x5;
|
||||
.asciz "GNU";
|
||||
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
|
||||
.long 4;
|
||||
.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI);
|
||||
.long 0;
|
||||
.popsection;
|
||||
#endif
|
||||
#endif // ARM || AARCH64
|
||||
|
||||
#endif // __ASSEMBLER__
|
||||
|
||||
#endif // OPENSSL_HEADER_ASM_BASE_H
|
@ -56,10 +56,6 @@
|
||||
|
||||
// This file should be the first included by all BoringSSL headers.
|
||||
|
||||
#include <ring_core_generated/prefix_symbols.h>
|
||||
|
||||
#include <ring-core/type_check.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
@ -71,40 +67,25 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_X86_64
|
||||
#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_X86
|
||||
#elif defined(__AARCH64EL__) || defined(_M_ARM64)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_AARCH64
|
||||
#elif defined(__ARMEL__) || defined(_M_ARM)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_ARM
|
||||
#elif defined(__MIPSEL__) && !defined(__LP64__)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_MIPS
|
||||
#elif defined(__MIPSEL__) && defined(__LP64__)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_MIPS64
|
||||
#elif defined(__wasm__)
|
||||
#define OPENSSL_32_BIT
|
||||
#else
|
||||
// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement,
|
||||
// little-endian architectures. Functions will not produce the correct answer
|
||||
// on other systems. Run the crypto_test binary, notably
|
||||
// crypto/compiler_test.cc, before adding a new architecture.
|
||||
#error "Unknown target CPU"
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include <ring-core/target.h> // IWYU pragma: export
|
||||
|
||||
#include <ring_core_generated/prefix_symbols.h>
|
||||
|
||||
#include <ring-core/type_check.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define OPENSSL_APPLE
|
||||
// Note |TARGET_OS_MAC| is set for all Apple OS variants. |TARGET_OS_OSX|
|
||||
// targets macOS specifically.
|
||||
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
|
||||
#define OPENSSL_MACOS
|
||||
#endif
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#define OPENSSL_IOS
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define OPENSSL_WINDOWS
|
||||
#endif
|
||||
|
||||
// *ring* doesn't support the `BORINGSSL_SHARED_LIBRARY` configuration, so
|
||||
|
139
include/ring-core/target.h
Normal file
139
include/ring-core/target.h
Normal file
@ -0,0 +1,139 @@
|
||||
/* Copyright (c) 2023, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_TARGET_H
|
||||
#define OPENSSL_HEADER_TARGET_H
|
||||
|
||||
// Preprocessor symbols that define the target platform.
|
||||
//
|
||||
// This file may be included in C, C++, and assembler and must be compatible
|
||||
// with each environment. It is separated out only to share code between
|
||||
// <ring-core/base.h> and <ring-core/asm_base.h>. Prefer to include those headers
|
||||
// instead.
|
||||
|
||||
#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_X86_64
|
||||
#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_X86
|
||||
#elif defined(__AARCH64EL__) || defined(_M_ARM64)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_AARCH64
|
||||
#elif defined(__ARMEL__) || defined(_M_ARM)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_ARM
|
||||
#elif defined(__MIPSEL__) && !defined(__LP64__)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_MIPS
|
||||
#elif defined(__MIPSEL__) && defined(__LP64__)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_MIPS64
|
||||
#elif defined(__wasm__)
|
||||
#define OPENSSL_32_BIT
|
||||
#else
|
||||
// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement,
|
||||
// little-endian architectures. Functions will not produce the correct answer
|
||||
// on other systems. Run the crypto_test binary, notably
|
||||
// crypto/compiler_test.cc, before adding a new architecture.
|
||||
#error "Unknown target CPU"
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define OPENSSL_APPLE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define OPENSSL_WINDOWS
|
||||
#endif
|
||||
|
||||
// Trusty isn't Linux but currently defines __linux__. As a workaround, we
|
||||
// exclude it here.
|
||||
// TODO(b/169780122): Remove this workaround once Trusty no longer defines it.
|
||||
#if defined(__linux__) && !defined(__TRUSTY__)
|
||||
#define OPENSSL_LINUX
|
||||
#endif
|
||||
|
||||
#if defined(__Fuchsia__)
|
||||
#define OPENSSL_FUCHSIA
|
||||
#endif
|
||||
|
||||
#if defined(__TRUSTY__)
|
||||
#define OPENSSL_TRUSTY
|
||||
#define OPENSSL_NO_POSIX_IO
|
||||
#define OPENSSL_NO_SOCK
|
||||
#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_NANOLIBC)
|
||||
#define OPENSSL_NO_POSIX_IO
|
||||
#define OPENSSL_NO_SOCK
|
||||
#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID_API__)
|
||||
#define OPENSSL_ANDROID
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define OPENSSL_FREEBSD
|
||||
#endif
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#define OPENSSL_OPENBSD
|
||||
#endif
|
||||
|
||||
// BoringSSL requires platform's locking APIs to make internal global state
|
||||
// thread-safe, including the PRNG. On some single-threaded embedded platforms,
|
||||
// locking APIs may not exist, so this dependency may be disabled with the
|
||||
// following build flag.
|
||||
//
|
||||
// IMPORTANT: Doing so means the consumer promises the library will never be
|
||||
// used in any multi-threaded context. It causes BoringSSL to be globally
|
||||
// thread-unsafe. Setting it inappropriately will subtly and unpredictably
|
||||
// corrupt memory and leak secret keys.
|
||||
//
|
||||
// Do not set this flag on any platform where threads are possible. BoringSSL
|
||||
// maintainers will not provide support for any consumers that do so. Changes
|
||||
// which break such unsupported configurations will not be reverted.
|
||||
#if !defined(OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED)
|
||||
#define OPENSSL_THREADS
|
||||
#endif
|
||||
|
||||
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE) && \
|
||||
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
||||
#define BORINGSSL_UNSAFE_DETERMINISTIC_MODE
|
||||
#endif
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define OPENSSL_ASAN
|
||||
#endif
|
||||
#if __has_feature(thread_sanitizer)
|
||||
#define OPENSSL_TSAN
|
||||
#endif
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#define OPENSSL_MSAN
|
||||
#define OPENSSL_ASM_INCOMPATIBLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_ASM_INCOMPATIBLE)
|
||||
#undef OPENSSL_ASM_INCOMPATIBLE
|
||||
#if !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#endif // OPENSSL_ASM_INCOMPATIBLE
|
||||
|
||||
#endif // OPENSSL_HEADER_TARGET_H
|
@ -71,5 +71,4 @@
|
||||
#define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
|
||||
#endif
|
||||
|
||||
|
||||
#endif // OPENSSL_HEADER_TYPE_CHECK_H
|
||||
|
12
third_party/fiat/asm/fiat_curve25519_adx_mul.S
vendored
12
third_party/fiat/asm/fiat_curve25519_adx_mul.S
vendored
@ -1,9 +1,7 @@
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(__x86_64__) && \
|
||||
(defined(__APPLE__) || defined(__ELF__))
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if defined(BORINGSSL_PREFIX)
|
||||
#include <boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
(defined(__APPLE__) || defined(__ELF__))
|
||||
|
||||
.intel_syntax noprefix
|
||||
.text
|
||||
@ -169,7 +167,3 @@ ret
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
@ -1,9 +1,7 @@
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(__x86_64__) && \
|
||||
(defined(__APPLE__) || defined(__ELF__))
|
||||
#include <ring-core/asm_base.h>
|
||||
|
||||
#if defined(BORINGSSL_PREFIX)
|
||||
#include <boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
(defined(__APPLE__) || defined(__ELF__))
|
||||
|
||||
.intel_syntax noprefix
|
||||
.text
|
||||
@ -137,7 +135,3 @@ ret
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user