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

issue hebasto openend this issue on June 28, 2024
  1. hebasto commented at 4:38 am on June 28, 2024: member

    Consider the following diff:

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

    It compiles fine:

    0$ ./autogen.sh
    1$ ./configure
    2$ make libsecp256k1.la
    

    However, it should fail like that:

     0$ ./autogen.sh
     1$ ./configure LDFLAGS="-Wl,--no-undefined"
     2$ make libsecp256k1.la
     3  CC       src/libsecp256k1_la-secp256k1.lo
     4  CC       src/libsecp256k1_precomputed_la-precomputed_ecmult.lo
     5  CC       src/libsecp256k1_precomputed_la-precomputed_ecmult_gen.lo
     6  CCLD     libsecp256k1_precomputed.la
     7  CCLD     libsecp256k1.la
     8/usr/bin/ld: src/.libs/libsecp256k1_la-secp256k1.o: in function `secp256k1_context_randomize':
     9/home/hebasto/git/secp256k1/secp256k1/src/secp256k1.c:770:(.text+0xee01): undefined reference to `undefined_function'
    10collect2: error: ld returned 1 exit status
    11make: *** [Makefile:1020: libsecp256k1.la] Error 1
    
  2. real-or-random added the label build on Jun 28, 2024
  3. real-or-random commented at 9:18 am on June 28, 2024: 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.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me