Skip to content

Commit adb107a

Browse files
committed
Introduce SECP256K1_LOCAL_VAR macro
This change makes the `-fvisibility=hidden` compiler option unnecessary.
1 parent 1988855 commit adb107a

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ noinst_HEADERS += src/assumptions.h
4747
noinst_HEADERS += src/checkmem.h
4848
noinst_HEADERS += src/testutil.h
4949
noinst_HEADERS += src/util.h
50+
noinst_HEADERS += src/util_defs.h
5051
noinst_HEADERS += src/int128.h
5152
noinst_HEADERS += src/int128_impl.h
5253
noinst_HEADERS += src/int128_native.h

src/precomputed_ecmult.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ extern "C" {
2626
static secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];
2727
static secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];
2828
#else /* !defined(EXHAUSTIVE_TEST_ORDER) */
29+
#include "util_defs.h"
2930
# define WINDOW_G ECMULT_WINDOW_SIZE
30-
extern const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];
31-
extern const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];
31+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];
32+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];
3233
#endif /* defined(EXHAUSTIVE_TEST_ORDER) */
3334

3435
#ifdef __cplusplus

src/precomputed_ecmult_gen.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ extern "C" {
1616
#ifdef EXHAUSTIVE_TEST_ORDER
1717
static secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
1818
#else
19-
extern const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
19+
#include "util_defs.h"
20+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
2021
#endif /* defined(EXHAUSTIVE_TEST_ORDER) */
2122

2223
#ifdef __cplusplus

src/util_defs.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef SECP256K1_UTIL_DEFS_H
2+
#define SECP256K1_UTIL_DEFS_H
3+
4+
/* Global variable visibility */
5+
/* See: https://github.com/bitcoin-core/secp256k1/issues/1181 */
6+
#if !defined(_WIN32) && defined(__GNUC__) && (__GNUC__ >= 4)
7+
# define SECP256K1_LOCAL_VAR extern __attribute__ ((visibility ("hidden")))
8+
#else
9+
# define SECP256K1_LOCAL_VAR extern
10+
#endif
11+
12+
#endif /* SECP256K1_UTIL_DEFS_H */

0 commit comments

Comments
 (0)