Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is default -Wl,--no-undefined desired? #1556

Open
hebasto opened this issue Jun 28, 2024 · 1 comment · May be fixed by #1559
Open

Is default -Wl,--no-undefined desired? #1556

hebasto opened this issue Jun 28, 2024 · 1 comment · May be fixed by #1559
Labels

Comments

@hebasto
Copy link
Member

hebasto commented Jun 28, 2024

Consider the following diff:

--- a/src/secp256k1.c
+++ b/src/secp256k1.c
@@ -765,7 +765,9 @@ int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context* ctx, secp256k1_pubkey
     return ret;
 }
 
+void undefined_function(void);
 int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *seed32) {
+    undefined_function();
     VERIFY_CHECK(ctx != NULL);
     ARG_CHECK(secp256k1_context_is_proper(ctx));
 

It compiles fine:

$ ./autogen.sh
$ ./configure
$ make libsecp256k1.la

However, it should fail like that:

$ ./autogen.sh
$ ./configure LDFLAGS="-Wl,--no-undefined"
$ make libsecp256k1.la
  CC       src/libsecp256k1_la-secp256k1.lo
  CC       src/libsecp256k1_precomputed_la-precomputed_ecmult.lo
  CC       src/libsecp256k1_precomputed_la-precomputed_ecmult_gen.lo
  CCLD     libsecp256k1_precomputed.la
  CCLD     libsecp256k1.la
/usr/bin/ld: src/.libs/libsecp256k1_la-secp256k1.o: in function `secp256k1_context_randomize':
/home/hebasto/git/secp256k1/secp256k1/src/secp256k1.c:770:(.text+0xee01): undefined reference to `undefined_function'
collect2: error: ld returned 1 exit status
make: *** [Makefile:1020: libsecp256k1.la] Error 1
@real-or-random
Copy link
Contributor

I think we want to check for undefined symbols, and -Wl,--no-undefined seems to be the canonical way of doing so.

I assume one important exception is builds with external default callbacks, so we can't enable it in these cases.

@hebasto hebasto linked a pull request Jun 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants