什么R_X86_64_32S和R_X86_64_64搬迁呢? [英] What do R_X86_64_32S and R_X86_64_64 relocation mean?

查看:255
本文介绍了什么R_X86_64_32S和R_X86_64_64搬迁呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

得到了下面的错误,当我试图编译在64位的FreeBSD C应用程序:

Got the following error when I tried to compile a C application in 64-bit FreeBSD:

搬迁R_X86_64_32S不能使用;与-fPIC编译

relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC

什么是 R_X86_64_32S 搬迁的,什么是 R_X86_64_64

What is R_X86_64_32S relocation and what is R_X86_64_64?

我GOOGLE了有关该错误的,它是可能的原因 - 这将会是巨大的,如果有人能告诉什么R_X86_64_32S的真正含义。

I've googled about the error, and it's possible causes - It'd be great if anyone could tell what R_X86_64_32S really means.

推荐答案

R_X86_64_32S R_X86_64_64 是名称重定位类型,为code编译的AMD64架构。你可以看看所有的人都起来了 AMD64 ABI
据此, R_X86_64_64 被分解为:

The R_X86_64_32S and R_X86_64_64 are names of relocation types, for code compiled for the amd64 architecture. You can look all of them up in the amd64 ABI. According to it, R_X86_64_64 is broken down to:


  • R_X86_64 - 所有的名字都与此pfixed $ P $

  • 64 - 64直接搬迁位

R_X86_64_32S 来:


  • R_X86_64 - preFIX

  • 32S - 截断到32位,符号扩展

这基本上意味着,在这两种情况下的符号价值受到这次搬迁,加上加数指着。对于 R_X86_64_32S 则链接验证生成的值登录扩展到原来的64位值。

which basically means "the value of the symbol pointed to by this relocation, plus any addend", in both cases. For R_X86_64_32S the linker then verifies that the generated value sign-extends to the original 64-bit value.

现在,在一个可执行文件中,code和数据段被赋予一个指定的虚拟基地址。可执行code未共享的,每个可执行文件都有自己的新的地址空间。这意味着,编译器知道确切位置数据部分将是,可以直接引用它。库,在另一方面,可以只知道他们的数据部分将在从基地址指定的偏移量;该基地址的值只能在运行时是已知的。因此,必须以code,它可以执行,无论它被放入内存中,被称为位置无关code(或PIC的简称)生产的所有库。

Now, in an executable file, the code and data segments are given a specified virtual base address. The executable code is not shared, and each executable gets its own fresh address space. This means that the compiler knows exactly where the data section will be, and can reference it directly. Libraries, on the other hand, can only know that their data section will be at a specified offset from the base address; the value of that base address can only be known at runtime. Hence, all libraries must be produced with code that can execute no matter where it is put into memory, known as position independent code (or PIC for short).

现在,当它涉及到解决您的问题,该错误信息本身就说明。

Now when it comes to resolving your problem, the error message speaks for itself.

这篇关于什么R_X86_64_32S和R_X86_64_64搬迁呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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