What does .rodata and -fPIC mean when compiling OpenSSL?

匆匆过客 提交于 2019-12-01 18:14:12

/usr/bin/ld: libcrypto.a(wp_block.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC libcrypto.a(wp_block.o): error adding symbols: Bad value

Effectively, it means you are building a shared object, but you did not specify -fPIC. PIC is position independent code, and it ensures addresses are relative to the program counter, so the code can be easily relocated (the module's base address can be changed easily and stuff just works).

I believe I've seen this issue on Fedora. Since you claim you are using it in your CFLAGS, try this instead:

$ make clean && make dclean
$ export CFLAGS="-fPIC"
$ ./config shared no-ssl2 ...
$ make
...

The make clean && make dclean will ensure all artifacts (including old object files) are cleaned.

Newer versions of OpenSSL respond to make distclean, not make dclean.


I am unsure what is libcrypto.a but apparently it is part of openssl.

That's the library where OpenSSL places the crypto and helper stuff, like AES, Cameilla, SHA, big integers, etc. libssl.a is where the SSL and TLS stuff goes. libssl.a depends upon libcrypto.a.


Newer version of OpenSSL cannot find their shared libraries after install. Also see Issue 3993, libssl.so.1.1: cannot open shared object file in the OpenSSL bug tracker.

You want to use static linking so the libraries do not break your executable. If so, then you may want to find uses of -lssl and -lcrypto in the Makefiles, and change them to -l:libssl.a and -l:libcrypto.a.

try tar -xf openssl-xxx.tar.gz instead of tar -zxvf openssl-xxx.tar.gz

And I don't known why it works for me!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!