Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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.
Posted
Updated 27-Mar-12 17:19pm
v3

But why use the rel prefix? Probably the constant data is relocatable and could therefor be moved around which would break the relative addressing. What happens if you remove it?
 
Share this answer
 
Comments
MaxLovic 27-Mar-12 10:43am    
Guess I did it, but not sure. Will try it.
MaxLovic 27-Mar-12 22:57pm    
Yep, the same result when 'rel' is removed. Even tried DEFAULT ABS just to be sure.
E.F. Nijboer 28-Mar-12 5:27am    
Found a link explaining -mdynamic-no-pic and I gives more insight on what it means. Indirectly it explains the given error.
http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/cpp/lin/compiler_c/copts/common_options/option_mdynamic_no_pic.htm
MaxLovic 5-Apr-12 5:56am    
Hi,
I've prepared a test project that shows the issue.
Please take a look here:
http://www.box.com/s/9e8f0f0b3ed6bbf22534
E.F. Nijboer 5-Apr-12 13:20pm    
I think you might be interested in this link, explaining about the GOT (global offset table).
https://developer.apple.com/library/mac/#documentation/DeveloperTools/nasm/nasmdoc8.html#section-8.2

Found the link above here by the way:
https://developer.apple.com/library/mac/#documentation/DeveloperTools/nasm/nasmdoc6.html#section-6.6.2

What if you change your absolute address to relative address. ie: .\data\mdynamic-no-pic.jpg or something like that.
 
Share this answer
 
Comments
MaxLovic 28-Mar-12 10:27am    
Not sure I understood your idea. You say instead of
pmullw xmm1, [rel const_w05]
I should write
pmullw xmm1, [.\rodata\const_w05]
right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900