NASM位置无关代码

NASM位置无关代码

本文介绍了OSX NASM位置无关代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

最近,我有一个任务要在MACOS下建立一个项目.挣扎于许多分歧,我终于走到了尽头,一切似乎都奏效,但一个问题困扰着我.

该项目具有如下的汇编(NASM)代码:

Hi.

Recently I''ve got a task to build a project under MACOS. Struggling many differences, I finaly got to an end, and everything seems to work, but one issue bothers me.

The project has assembly (NASM) code like this:

SECTION .rodata align=16

ALIGN 16
const_w05: times 8 dw 5


SECTION .text

ALIGN16
_some_function_sse2:
...
pmullw      xmm1,   [rel const_w05]
...
ret



现在谈到链接时,出现以下错误:
ld:(_ some_function_sse2)中使用的绝对寻址(也许是-mdynamic-no-pic),...在可滑动图像中不允许.使用"-read_only_relocs抑制"来启用文本重定位

因此,在阅读大量信息之后,我没有发现建议的选项 -read_only_relocs抑制的错误.该项目已建立并运行.

但是,如果共享库加载到不同的内存位置,恐怕它是不正确的,并且可能无法正常工作.

顺便说一句:该项目是一个共享库(动态库).

PS2:一切都建立在LINUX上,没有任何此类错误.



Now whe it comes to linking, I get the following error:
ld: absolute addressing (perhaps -mdynamic-no-pic) used in (_some_function_sse2) from ... not allowed in slidable image. Use ''-read_only_relocs suppress'' to enable text relocs

So reading lot of information on this, I had nothing bug put the suggested option -read_only_relocs suppress. The project was built and worked.

But I''m afraid it isn''t correct and may not work if the shared object loads in different memory location.

BTW: The project is a shared object (dynamic library).

PS2: Everything builds on LINUX with no such errors.

推荐答案



这篇关于OSX NASM位置无关代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:37