编译OpenSSL时.rodata和-fPIC是什么意思? [英] What does .rodata and -fPIC mean when compiling OpenSSL?

查看:233
本文介绍了编译OpenSSL时.rodata和-fPIC是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译openssl,但是遇到错误.使用的CFLAGS是:

I am trying to compile openssl but encountering an error. The CFLAGS in use are:

-O2 -fPIC -fno-strict-overflow

有人可以向我解释什么是.rodata,以下句子是什么意思?

Can someone explain to me please what is .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

我不确定libcrypto.a是什么,但显然它是openssl的一部分.

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

这怎么可能解决?

推荐答案

/usr/bin/ld:libcrypto.a(wp_block.o):在创建共享库时,无法使用针对".rodata"的重定位R_X86_64_32S;用-fPIC libcrypto.a(wp_block.o)重新编译:错误添加符号:错误值

/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

有效地,这意味着您正在构建共享库,但未指定-fPIC. PIC是位置无关的代码,它可以确保地址相对于程序计数器,因此可以轻松地重新定位代码(可以轻松更改模块的基地址,并且可以正常工作).

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).

我相信我已经在Fedora上看到了这个问题.由于您声称要在CFLAGS中使用它,因此请尝试以下操作:

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
...

make clean && make dclean将确保清除所有工件(包括旧的目标文件).

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

较新版本的OpenSSL响应make distclean,而不响应make dclean.

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

我不确定libcrypto.a是什么,但显然它是openssl的一部分.

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

这是OpenSSL存放加密和帮助程序内容的库,例如AES,Cameilla,SHA,大整数等.libssl.a是SSL和TLS内容所在的位置. libssl.a取决于libcrypto.a.

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.

较新版本的OpenSSL在安装后找不到其共享库.另请参见问题3993,libssl.so.1.1:无法打开共享对象文件 OpenSSL错误跟踪器.

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.

您要使用静态链接,以便这些库不会破坏您的可执行文件.如果是这样,那么您可能想在Makefile中找到-lssl-lcrypto的用法,并将它们更改为-l:libssl.a-l:libcrypto.a.

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.

这篇关于编译OpenSSL时.rodata和-fPIC是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆