aboutsummaryrefslogtreecommitdiff
path: root/crypto/crypto.c
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2017-10-18 22:23:09 -0400
committerCQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>2017-10-23 18:36:49 +0000
commit38636aba74400272afbb7155bbdfef86be6ed715 (patch)
tree79f5fac63449e1334db027e689c45c72278ee031 /crypto/crypto.c
parent3b358b25b08f529021bc443031eae7c0cc215d40 (diff)
downloadboringssl-38636aba74400272afbb7155bbdfef86be6ed715.zip
boringssl-38636aba74400272afbb7155bbdfef86be6ed715.tar.gz
boringssl-38636aba74400272afbb7155bbdfef86be6ed715.tar.bz2
Hide CPU capability symbols in C.
Our assembly does not use the GOT to reference symbols, which means references to visible symbols will often require a TEXTREL. This is undesirable, so all assembly-referenced symbols should be hidden. CPU capabilities are the only such symbols defined in C. These symbols may be hidden by doing at least one of: 1. Build with -fvisibility=hidden 2. __attribute__((visibility("hidden"))) in C. 3. .extern + .hidden in some assembly file referencing the symbol. We have lots of consumers and can't always rely on (1) happening. We were doing (3) by way of d216b71f909fe56255813dab0a8d052534bdcb91 and 16e38b2b8f50a3d048f61d2979d5ceddacd70fc3, but missed 32-bit x86 because it doesn't cause a linker error. Those two patches are not in upstream. Upstream instead does (3) by way of x86cpuid.pl and friends, but we have none of these files. Standardize on doing (2). This avoids accidentally getting TEXTRELs on some 32-bit x86 build configurations. This also undoes d216b71f909fe56255813dab0a8d052534bdcb91 and 16e38b2b8f50a3d048f61d2979d5ceddacd70fc3. They are no now longer needed and reduce the upstream diff. Change-Id: Ib51c43fce6a7d8292533635e5d85d3c197a93644 Reviewed-on: https://boringssl-review.googlesource.com/22064 Commit-Queue: Matt Braithwaite <mab@google.com> Reviewed-by: Matt Braithwaite <mab@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Diffstat (limited to 'crypto/crypto.c')
-rw-r--r--crypto/crypto.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/crypto/crypto.c b/crypto/crypto.c
index 390cd8b..9f4639f 100644
--- a/crypto/crypto.c
+++ b/crypto/crypto.c
@@ -40,6 +40,18 @@
OPENSSL_ARM || OPENSSL_AARCH64) */
+// Our assembly does not use the GOT to reference symbols, which means
+// references to visible symbols will often require a TEXTREL. This is
+// undesirable, so all assembly-referenced symbols should be hidden. CPU
+// capabilities are the only such symbols defined in C. Explicitly hide them,
+// rather than rely on being built with -fvisibility=hidden.
+#if defined(OPENSSL_WINDOWS)
+#define HIDDEN
+#else
+#define HIDDEN __attribute__((visibility("hidden")))
+#endif
+
+
// The capability variables are defined in this file in order to work around a
// linker bug. When linking with a .a, if no symbols in a .o are referenced
// then the .o is discarded, even if it has constructor functions.
@@ -57,11 +69,11 @@
// archive, linking on OS X will fail to resolve common symbols. By
// initialising it to zero, it becomes a "data symbol", which isn't so
// affected.
-uint32_t OPENSSL_ia32cap_P[4] = {0};
+HIDDEN uint32_t OPENSSL_ia32cap_P[4] = {0};
#elif defined(OPENSSL_PPC64LE)
-unsigned long OPENSSL_ppc64le_hwcap2 = 0;
+HIDDEN unsigned long OPENSSL_ppc64le_hwcap2 = 0;
#elif defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
@@ -69,7 +81,7 @@ unsigned long OPENSSL_ppc64le_hwcap2 = 0;
#if defined(OPENSSL_STATIC_ARMCAP)
-uint32_t OPENSSL_armcap_P =
+HIDDEN uint32_t OPENSSL_armcap_P =
#if defined(OPENSSL_STATIC_ARMCAP_NEON) || defined(__ARM_NEON__)
ARMV7_NEON |
#endif
@@ -88,7 +100,7 @@ uint32_t OPENSSL_armcap_P =
0;
#else
-uint32_t OPENSSL_armcap_P = 0;
+HIDDEN uint32_t OPENSSL_armcap_P = 0;
#endif
#endif