Emit #if guards for ARM assembly files.

This change causes the generated assembly files for ARM and AArch64 to
have #if guards for __arm__ and __aarch64__, respectively. Since
building on ARM is only supported for Linux, we only have to worry about
GCC/Clang's predefines.

Change-Id: I7198eab6230bcfc26257f0fb6a0cc3166df0bb29
Reviewed-on: https://boringssl-review.googlesource.com/5173
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
Adam Langley 2015-06-22 16:21:14 -07:00
parent 2cac3506fa
commit 9eaf07d460
3 changed files with 10 additions and 1 deletions

View File

@ -23,6 +23,7 @@
# /opt/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -O3 -mcpu=cortex-a8 -mfpu=neon -fpic -DASM_GEN -I ../../include -S chacha_vec.c -o -
#if !defined(OPENSSL_NO_ASM)
#if defined(__arm__) || defined(__aarch64__)
.syntax unified
.cpu cortex-a8
@ -1423,4 +1424,5 @@ CRYPTO_chacha_20_neon:
.ident "GCC: (Linaro GCC 2014.11) 4.9.3 20141031 (prerelease)"
.section .note.GNU-stack,"",%progbits
#endif /* __arm__ || __aarch64__ */
#endif /* !OPENSSL_NO_ASM */

View File

@ -52,7 +52,8 @@ func main() {
output.WriteString(compiler)
output.WriteString(" ")
output.WriteString(strings.Join(args, " "))
output.WriteString("\n\n#if !defined(OPENSSL_NO_ASM)\n\n")
output.WriteString("\n\n#if !defined(OPENSSL_NO_ASM)\n")
output.WriteString("#if defined(__arm__) || defined(__aarch64__)\n\n")
cmd := exec.Command(compiler, args...)
cmd.Stderr = os.Stderr
@ -144,5 +145,6 @@ const attr28Block = `
`
const trailer = `
#endif /* __arm__ || __aarch64__ */
#endif /* !OPENSSL_NO_ASM */
`

View File

@ -116,6 +116,9 @@ sub expand_line {
return $line;
}
print "#if defined(__arm__)\n" if ($flavour eq "linux32");
print "#if defined(__aarch64__)\n" if ($flavour eq "linux64");
while($line=<>) {
if ($line =~ m/^\s*(#|@|\/\/)/) { print $line; next; }
@ -162,4 +165,6 @@ while($line=<>) {
print "\n";
}
print "#endif" if ($flavour eq "linux32" || $flavour eq "linux64");
close STDOUT;