cryptobiu / libscapi

Comprehensive Open Source Library for Secure Multiparty Computation
MIT License
180 stars 66 forks source link

Error while building examples #49

Closed JulianLiedtke closed 5 years ago

JulianLiedtke commented 6 years ago

I get an error while building the examples:

/libscapi/samples$ make
g++ -std=c++14 -I../../boost_1_64_0 -I../install/include -I../lib/OTExtensionBristol -I../install/include/libOTe -I../install/include/libOTe/cryptoTools -O3 -Wall -Wno-unused-function -Wno-unused-variable examples_main.cpp -o libscapi_example simple_dlog.o simple_sha1.o simple_gmac.o CommitmentExample.o OTExample.o SigmaProtocolExample.o comm_example.o App1.o YaoParties.o OTExtensionBristolExample.o ../libscapi.a ../install/lib/libOTExtensionBristol.a ../install/lib/libOTe.a ../install/lib/libcryptoTools.a ../install/lib/libmiracl.a ../install/lib/libsimpleot.a -L../install/lib -L../../boost_1_64_0/stage/lib ../install/lib/libcrypto.a -ldl -lboost_log -lboost_system -lboost_thread -lboost_serialization -lboost_filesystem -lpthread ../install/lib/libssl.a -lgmp -lrt
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_lookup_niels.o): relocation R_X86_64_32S against symbol `CONST_2P0' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(gfe4x_square.o): relocation R_X86_64_32S against symbol `scale19' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(gfe4x_mul.o): relocation R_X86_64_32S against symbol `scale19' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge4x_double_p1p1.o): relocation R_X86_64_32S against symbol `scale19' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge4x_add_p1p1.o): relocation R_X86_64_32S against symbol `Gk' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge4x_niels_add_p1p1.o): relocation R_X86_64_32S against symbol `scale19' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge4x_lookup_niels.o): relocation R_X86_64_32S against symbol `_allone' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge4x_lookup.o): relocation R_X86_64_32S against symbol `_allone' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(fe25519_freeze.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(fe25519_mul.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(fe25519_nsquare.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(fe25519_square.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_dbl_p1p1.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_add_p1p1.o): relocation R_X86_64_32S against symbol `CONST_2P0' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_nielsadd2.o): relocation R_X86_64_32S against symbol `CONST_2P0' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_p1p1_to_p2.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: ../install/lib/libsimpleot.a(ge25519_p1p1_to_p3.o): relocation R_X86_64_32S against symbol `CONST_REDMASK51' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
makefile:11: recipe for target 'libscapi_example' failed
make: *** [libscapi_example] Error 1
holycleugh commented 5 years ago

I get this too while trying to build the samples. Were you able to find a solution?

holycleugh commented 5 years ago

As mentioned on my issue https://github.com/cryptobiu/libscapi/issues/52, it works if you add the -no-pie option to CXX in samples' makefile, so it looks like CXX = g++ -std=c++14 $(INC) -O3 -Wall -Wno-unused-function -Wno-unused-variable -no-pie. Then, e.g., run ./libscapi_example yao 1 Yao/YaoConfig.txt and ./libscapi_example yao 2 Yao/YaoConfig.txt in different shells.

liorko87 commented 5 years ago

@holycleugh thank you for your comment. I updated the makefile according to your recommendation.

holycleugh commented 5 years ago

Hi @liorko87, I know it works, but is this the proper way to do it? I know that PIE is a security feature, so it would be nice to have it. Maybe some different options when compiling libscapi?

mkskeller commented 5 years ago

I think I've managed to fix it: https://github.com/mkskeller/SimpleOT/commit/3b84cdb035805761f82f2bcf14b0cd73a58dbe1a