Skip to content

question: Build library without standard IO functions #262

@ssantos21

Description

@ssantos21

I'm using secp256k1-zkp as a library in an Intel SGX Enclave project.
When any secp256k1-zkp function is called in the untrusted environment, the project builds successfully.
But I got the error below when secp256k1-zkp functions are called in Enclave trusted environment.

The reason, I think, is taht the secp256k1-zkp library seems to have references to fprintf and stderr, which are standard C library functions and global variables.
In the context of Intel SGX enclaves, the standard C library is not directly accessible in the same manner as regular applications.

So the linker (/usr/local/bin/ld) is unable to find references for stderr and __fprintf_chk, causing the "undefined reference" error.

Is there a way to compile the secp256k1-zkp library in a way that doesn't reference any functionality that isn't supported inside an enclave, like standard IO functions?

/usr/local/bin/ld: secp256k1-zkp/.libs/libsecp256k1.a(libsecp256k1_la-secp256k1.o): warning: relocation against `stderr' in read-only section `.text'
/usr/local/bin/ld: secp256k1-zkp/.libs/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `fprintf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:105: undefined reference to `stderr'
/usr/local/bin/ld: /usr/include/x86_64-linux-gnu/bits/stdio2.h:105: undefined reference to `__fprintf_chk'
/usr/local/bin/ld: /usr/include/x86_64-linux-gnu/bits/stdio2.h:105: undefined reference to `stderr'
/usr/local/bin/ld: /usr/include/x86_64-linux-gnu/bits/stdio2.h:105: undefined reference to `__fprintf_chk'
/usr/local/bin/ld: warning: creating DT_TEXTREL in a PIE

I am building the secp256k1-zkp lib with --enable-module-schnorrsig --enable-experimental --enable-module-musig flags and including ./secp256k1-zkp/.libs/libsecp256k1.a in the main project build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions