问题标签 [fpic]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
cmake - 使用 -fPIC Gentoo 重新编译
我是 Gentoo 的新手,并尝试使用 CMake 安装一个名为 TexGen ( http://texgen.sourceforge.net/index.php/Main_Page ) 的 3D 建模程序,但我不断收到错误消息:
这发生在以下步骤中:
我已经查看了所有内容并尝试在 cmake 选项文件中设置 -fPIC 标志,但结果没有任何变化。正如我所说,我对 Linux 和 Gentoo 还是很陌生(大约几周),任何帮助都将不胜感激。
c - Address of global symbol table (GOT) in PIC/PIE binaries
I am maintaining the JIT compiler for the virtual machine in ioquake3.
Recently someone tried to build a PIE binary from ioquake3, however compiled code makes extensive use of the EBX register which in PIC code and thus PIE binaries seems to be a fixed register containing the GOT address.
The virtual machine may call into GCC-compiled code at a fixed point so there I will need to restore EBX to the GOT address. For that the JIT-compiler code needs to know the GOT address so that it can emit code that restores EBX to that address. I imagine you could directly use inline assembly like so:
Compiled code is directly called from the JIT-compiler code so EBX should be the same at JIT compile and at the call into the VM. My question is: would this work, and is there a different way to retrieve the GOT address from C code, for instance, is there a symbol defined that specifies that address, or is there a function that returns it?
c++ - 为什么包含 -fPIC 来编译静态库会导致运行时出现分段错误?
我正在用 g++ 编译 C++ 静态库并使用 -fPIC 选项。我必须使用 -fPIC 选项,因为最终该库将与其他静态库链接以形成动态库。
当我在本地测试静态库时,当我不包含 -fPIC 选项时它工作得很好。但是,当我使用 -fPIC 编译库时,在调用其中一个函数时,我会在运行时收到分段错误错误。
包括 -fPIC 来编译静态库的哪些原因会导致运行时出现分段错误?
c++ - 如何在 CMake 中链接库依赖项的 PIC 版本?
制作:
我们依赖于cpp-netlib。
我们从源代码构建它作为我们构建系统的一部分。
cpp-netlib/CMakeLists.txt
:
对于一个特定的用例,我们必须在共享库中使用它,所以我创建了第二个-fPIC
启用的库:
在我的共享库目标中,然后我链接到libcpp-netlib_pic.a
foo/CMakeLists.txt
:
我收到了一个链接器错误,因为我cpp-netlib
正在尝试链接非 pic 版本boost_network
解构名称:
提升构建:
这都是将我们现有的构建系统从 boost-build 迁移到 CMake 的一部分。
boost-build Jamfile 工作正常。
Jamroot
:
cpp-netlib/Jamfile
:
foo/Jamfile
:
这行得通。
boost::network
请注意,虽然 中有一个子文件夹,但没有提及任何地方,cpp-netlib/boost/library
但它仅包含标题。
问题:
我如何告诉 CMakecpp-netlib_pic
需要使用 pic 版本boost_network
?
c++ - 如何配置 CMake 以使用 -fPIC 构建库?
我正在尝试创建一个-fPIC
指定的静态库。
这行不通。
库 ( cpp-netlib_pic
) 是在没有-fPIC
标志的情况下构建的。
然而,链接的其他目标已经添加到cpp-netlib_pic
它们-fPIC
的编译器标志中,但是链接失败,因为cpp-netlib_pic
没有。
这里foo
将-fPIC
添加:
我已经用 make VERBOSE=1 向自己证明了这一点
注意-fPIC
这里没有。
构建foo
使用的目标时cpp-netlib_pic
,-fPIC
出现:
如何配置 CMake 来构建第一个库(cpp-netlib_pic
)-fPIC
?
c - 将 Python 嵌入到 C 时无法创建共享库
我正在尝试制作一个共享库,它由一个 C 头文件和两个 C 源文件组成,其中一个调用 Python 文件来实现。使用的编译命令是
gcc -fPIC -c -II/usr/local/include -I/usr/local/include -I/usr/local/include/python3.4m -I/usr/local/include/python3.4m -DNDEBUG -g - fwrapv -O0 -Wall -Wstrict-prototypes -DDOUBLE_PRECISION *.c
我能够编译所有这些而没有任何错误,但是当我尝试使用以下命令创建共享对象文件时
gcc *.o -L/usr/local/lib -lpthread -ldl -lutil -lm -Xlinker -export-dynamic /usr/local/lib/python3.4/config-3.4m/libpython3.4m.a -shared - o libroughness.so
我收到以下我无法解决的错误
/usr/bin/ld: /usr/local/lib/python3.4/config-3.4m/libpython3.4m.a(abstract.o): 重定位 R_X86_64_32S 反对 `_PyObject_NextNotImplemented' 在制作共享对象时不能使用;使用 -fPIC /usr/local/lib/python3.4/config-3.4m/libpython3.4m.a 重新编译:无法读取符号:错误值 collect2:ld 返回 1 退出状态
我在编译时使用 -fPIC 标记,但它仍然要求我使用 fPIC 重新编译。任何有关如何解决此案的帮助将不胜感激。
cmake - 在 CMakeList.txt 中检测 32 位 x86 处理器?
由于缺少-fPIC
. _ 她来自 ci20 MIPS 开发板:
由于注册压力,该项目的政策是除了 32 位 x86 之外的所有地方都向我们提供 PIC。这意味着 x86_64、ARM-32、Aarch32、Aarch64、MIPS、MIPS64、UltraSparc 等获得 PIC。
我相信目标处理器是在CMAKE_SYSTEM_PROCESSOR
. 我遇到的问题是文档没有告诉我值,所以我无法弄清楚如何制作“非 32 位 x86”测试。
如何在 CMakeList.txt 中检测 32 位 x86 处理器?
更好的是,我希望看到 CMake 设置的处理器的完整列表CMAKE_SYSTEM_PROCESSOR
。如果有人有清单,那么提供它会很棒。
c - gcc 优化对共享库操作的影响
我有一个自己的共享库,编译和链接如下:
我有一个程序(nr
)使用这个库:
如果调用共享库的函数之一,则调用 POSIX 消息发送 ( mq_send()
) 可能会导致断言错误。strace ./nr
对此有以下说法:
非常有趣的是,如果我使用除默认值(例如-O3
)以外的任何优化级别编译程序,一切正常:
在这种情况下strace ./nr
说:
这正是我独立于优化级别所期望的。
造成这种情况的可能原因是什么?
对应的代码片段:
fprintf
mq_send
在:之前打印
这很好,但是调用mq_send
会产生上述详细的断言。
c++ - 链接错误:“重定位 R_X86_64_32 ... 制作共享对象时无法使用;使用 -fPIC 重新编译”
我正在尝试编译 Tox(特别是 toxcore)。当我尝试编译它时,遇到以下错误:
在错误消息之后,我尝试fPIC
通过导出 C++ 标志 ( )、向( )export CXXFLAGS="$CXXFLAGS -fPIC"
添加参数和编辑(更改为)来使用,但这些尝试没有奏效,我仍然遇到相同的错误。可能出了什么问题?configure
./configure --enable-shared
Makefile
CC = gcc
CC = gcc -fPIC
这是我现在的方法(在 Ubuntu 上):
c++ - g++ -fPIC 不产生与位置无关的代码
我已阅读主题GCC -fPIC option
所以我创建了我的 testlib.cpp。
当我编译为 g++ -c -o testlib.o testlib.cpp 和 g++ -fPIC -c -o testlib.o testlib.cpp 时,testlib.o 的相应 objdump 是相同的:
objdump -d testlib.o -M intel
而且我希望在使用 -fPIC 编译时,跳转和je命令的参数地址与位置无关。所以这两个objdumps应该是不同的。我理解错了什么?