[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Calling x86 code from 64-bit code



Goswin von Brederlow wrote:
The easiest would be to allocate the program completly in the 32 bit
address space. Converting pointers is then just a matter of extending
them.

Isn't it possible to allocate 32-bit space inside 64-bit one?
Besides, I am absolutely unaware of the calling conventions between
32 and 64-bit bytecode ; here's the idiotic test I did:

// compiled in 32-bit using gcc -shared ..
void foo()
  printf("foo!\n");
}

// compiled in 64-bit with -lfoo
extern void foo(void);
int main() {
  foo();
}

Of course ldd was horrified but did link anyway, and the program
just.. crashed when calling foo()

I imagine I should have used something like:
extern __magicGccKeyword32 void foo(void);

And more magic when linking.

Any references to start with? The gcc manual is really not very
helpful - is the only way to learn x86-64 and write the function
calls by hand, playing with asm {} things ?

 ---
Xavier Roche
roche at httrack dot com



Reply to: