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

I am trying to compile openssl but have encountered an error. Used CFLAGS:

-O2 -fPIC -fno-strict-overflow 

Can someone please explain to me what .rodata and what the following sentence means?

 /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 

I'm not sure what libcrypto.a is, but apparently it is part of openssl.

How can this be fixed?

+5
source share
2 answers

/ usr / bin / ld: libcrypto.a (wp_block.o): moving R_X86_64_32S against `.rodata 'cannot be used when creating a shared object; recompile with -fPIC libcrypto.a (wp_block.o): characters with errors added: Bad value

In fact, this means that you are creating a shared object, but you did not specify -fPIC . PIC is a position-independent code, and it ensures that the addresses refer to the software counter, so the code can be easily moved (the base address of the module can be easily changed, and the material just works).

I believe that I saw this problem on Fedora. Since you claim to use it in your CFLAGS , try this instead:

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

make clean && make dclean will clean all artifacts (including old object files).

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


I'm not sure what libcrypto.a is, but apparently it is part of openssl.

This is a library in which OpenSSL hosts cryptographic and auxiliary elements such as AES, Cameilla, SHA, large integers, etc. libssl.a is where SSL and TLS connect. libssl.a dependent on libcrypto.a .


A newer version of OpenSSL cannot find its shared libraries after installation. Also see Problem 3993, libssl.so.1.1: Cannot open the shared objects file in the OpenSSL error tracker.

You want to use static linking so that libraries do not violate your executable. If so, then you might want to find the use of -lssl and -lcrypto in Make files and change them to -l:libssl.a and -l:libcrypto.a .

+12
source

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

And I don’t know why this works for me!

0
source

Source: https://habr.com/ru/post/1200982/


All Articles