Skip to content

Commit 275ec53

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

4 files changed

+20
-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_local_visibility.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

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313

1414
#include "ecmult.h"
1515
#include "group.h"
16+
#include "util_local_visibility.h"
17+
1618
#if defined(EXHAUSTIVE_TEST_ORDER)
1719
# if EXHAUSTIVE_TEST_ORDER == 7
1820
# define WINDOW_G 3
@@ -27,8 +29,8 @@ static secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];
2729
static secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];
2830
#else /* !defined(EXHAUSTIVE_TEST_ORDER) */
2931
# 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)];
32+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_pre_g[ECMULT_TABLE_SIZE(WINDOW_G)];
33+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_pre_g_128[ECMULT_TABLE_SIZE(WINDOW_G)];
3234
#endif /* defined(EXHAUSTIVE_TEST_ORDER) */
3335

3436
#ifdef __cplusplus

src/precomputed_ecmult_gen.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ extern "C" {
1313

1414
#include "group.h"
1515
#include "ecmult_gen.h"
16+
#include "util_local_visibility.h"
17+
1618
#ifdef EXHAUSTIVE_TEST_ORDER
1719
static secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
1820
#else
19-
extern const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
21+
SECP256K1_LOCAL_VAR const secp256k1_ge_storage secp256k1_ecmult_gen_prec_table[COMB_BLOCKS][COMB_POINTS];
2022
#endif /* defined(EXHAUSTIVE_TEST_ORDER) */
2123

2224
#ifdef __cplusplus

src/util_local_visibility.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef SECP256K1_LOCAL_VISIBILITY_H
2+
#define SECP256K1_LOCAL_VISIBILITY_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_LOCAL_VISIBILITY_H */

0 commit comments

Comments
 (0)