flat assembler
Message board for the users of flat assembler.
Index
> Linux > Import 64bit functions from 32bit program? |
Author |
|
revolution 30 Sep 2012, 08:14
It is possible, but you need support from the OS to switch modes. Also be aware that the addressing would likely need to all be below the 4G limit and the page tables would need to match. I have no idea if Linux supports such a scheme as this:
http://board.flatassembler.net/topic.php?p=140791#140791 |
|||
30 Sep 2012, 08:14 |
|
JohnFound 30 Sep 2012, 09:09
Maybe I have to explain more detailed what I actually need. It is known that 64bit Linux can run 32 bit applications natively but only if they does not use shared libraries. 32bit system calls are kernel supported.
There is a 32bit compatibility package that contains all needed 32bit libraries but it have to be installed. Otherwise, LD linker will not be able to find needed libraries and will fail to load application. On the other hand, in FreshLib, because of its architecture, I have wrapper functions for all needed functions imported from the shared libraries. So, I can make Linux64 layer that to import directly from 64bit libraries and this way to allow FreshLib applications to run on 64bit Linux without installing 32bit compatibility package. Another way is to implement all needed functionality using only system calls, what is possible, but not practical in this moment. |
|||
30 Sep 2012, 09:09 |
|
revolution 30 Sep 2012, 11:21
How would your asm file look? Like this?
Code: use64 start64: ;wrapper code for 64-bit shared library access jmp seg32:start32 shared_library_func_1: call shared_library_func retf finished: mov rax,something int 0x80 use32 start32: call seg64:shared_library_func_1 ;... call seg64:finished |
|||
30 Sep 2012, 11:21 |
|
JohnFound 30 Sep 2012, 12:28
Well, I have no experience in 64 bit programming. Maybe something like:
Code: use32 proc GetMem, .size begin ; switch to 64bit , call libc64 "alloc" use64 ;something more??? invoke64 alloc, [.size] use32 ; switch back to 32bit and return the address in 32bit (if possible) return endp start: stdcall GetMem, 1024 stdcall FreeMem, eax stdcall Terminate, 0 |
|||
30 Sep 2012, 12:28 |
|
revolution 30 Sep 2012, 12:45
You have to get cooperation from the OS to switch operating mode. You can't do it only with user mode code. You have to either change the current segment descriptor or select another descriptor that is already prepared.
Also, if you allocate memory in 64-bit mode then how do you ensure it is accessible in 32-bit mode? The memory regions might be very different. |
|||
30 Sep 2012, 12:45 |
|
JohnFound 30 Sep 2012, 12:54
Yes, I am sure that this is what I have to do. Maybe Linux64 has some syscall about changing modes?
|
|||
30 Sep 2012, 12:54 |
|
LocoDelAssembly 30 Sep 2012, 13:06
Sorry I can´t give a thorough look into this so this link may not be helpful: http://en.wikipedia.org/wiki/X32_ABI (also notice that perhaps this is not here yet)
|
|||
30 Sep 2012, 13:06 |
|
revolution 30 Sep 2012, 13:24
LocoDelAssembly wrote: Sorry I can´t give a thorough look into this so this link may not be helpful: http://en.wikipedia.org/wiki/X32_ABI (also notice that perhaps this is not here yet) |
|||
30 Sep 2012, 13:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.