How to mov EAX, &func?

Mehrdad wfunction at hotmail.com
Wed May 16 02:40:07 PDT 2012


On Wednesday, 16 May 2012 at 07:05:10 UTC, Walter Bright wrote:
> On 5/15/2012 12:33 PM, Mehrdad wrote:
>> How do get the address of a function in naked assembly code?
>>
>> void foo()
>> {
>> asm
>> {
>> naked;
>> mov EAX, &foo;
>> }
>> }
>>
>> This doesn't work...
>
> I know, but also be aware that even if it did work, it would 
> not work in the presence of PIC code and shared libraries. It's 
> best if you stick to using D code to get the address of a 
> function, which accounts for all these variations and wierdness.

Yeah I know, but currently shared libraries are the least of my 
worries.

The trouble with 'sticking to D code' is that, well, I can't... 
it's naked...


More information about the Digitalmars-d mailing list