c - Linux/海湾合作委员会 : null address "00000000" with pthread compiler option

标签 c linux gcc pthreads

我用 pthreads 编译了一个共享库。为什么我使用 pthread 选项编译时地址是“00000000”?这意味着什么 ? pthread_create 是否嵌入到二进制文件中?

(无论如何,两种方法都按预期工作)

这是使用 -lpthread 的 objdump 输出

00000000      DF *UND*  00000aa5  GLIBC_2.1   pthread_create

这是使用 -pthread 的 objdump 输出

00000000      D  *UND*  00000000              pthread_create

最佳答案

它还没有搬迁。

现代操作系统上的可执行文件通常使用偏移量而不是直接地址。这样您就可以在任何地址加载可执行文件,但您需要为此处理所有偏移量。每种可执行文件格式都有专门的部分,指示重定位的内容和方式(例如 ELF 格式上的 .reloc)。

有关搬迁的更多信息和链接 herehere .

关于c - Linux/海湾合作委员会 : null address "00000000" with pthread compiler option,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11140808/

相关文章:

c - 如何在 alpine 上编译 32 位的 hello world?

c++ - c 中的 pow() 函数给我带来错误的结果

c - 使用数组索引将值直接存储到 C 结构中

mysql - 启用 MySQL 系统日志以记录中止的连接和拒绝访问

c++ - <内置> :1:2: warning: use of C++0x long long integer constant [-Wlong-long]

c - free() 是否将内存归零?

c - 数组的长度比需要的长

c - 操作二维数组中的元素

linux - 比较每行的多个列

linux - 使用带有 Go 和 GoCV 的 OpenVINO 加载预训练的 DNN 模型 - 符号查找错误