Menu

#196 Support self-relative addresses to data

open
nobody
None
5
2014-08-26
2013-07-26
A Fog
No

NASM does not support self-relative addresses from code to data, but YASM does. As YASM is no longer maintained, I have to port my code to NASM. Therefore this request.

I am making self-relative code in 32 bit mode without a GOT in this way:

.data
mydata dd 0

.code
call get_esp_into_ecx
ecx_points_here:
mov eax,[ecx + (mydata - ecx_points_here]  ; read mydata
ret

get_esp_into_ecx:
mov ecx,[esp]         ; this function reads its own return address
ret

This is the same method that is used for making position-independent code in a Unix shared object, except I want to get rid of the slow GOT lookup.

As I said, this works in YASM, while NASM says error: beroset-p-637-invalid effective address
What is needed is a self-relative address, similar to the rip-relative address in 64-bit mode.

Discussion

  • Cyrill Gorcunov

    Cyrill Gorcunov - 2013-07-26

    Could you please use bugzilla.nasm.us for future requests, we're trying to minimize use of SF buckracking.

     
  • A Fog

    A Fog - 2013-07-27
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.