Possible?: statically converting i386 ELF object files to ARM ELF object files
Hello everybody,
(please quote my email address on a reply to this email, I am not member of the list, thanks.)
I have wondered wether the code conversion ability of qemu could be utilized to convert ELF .o object files compiled for i386 Linux by GCC to .o object files for ARM/Linux. Is this possible or has something been attempted in this direction?
The need for such conversion occurs when porting the Java MIDP to ARM. Due to export restrictions, for some cryptography code in the MIDP, only linkable object files for i386 are available with the sources. (Half a dozen small object files, clearly named like MD2.o MD5.o SHA1.o, ...).
Thanks in advance,
Sebastian
Quoted 10 lines · Sebastian Nowozin
Hello everybody,
(please quote my email address on a reply to this email, I am not member of the list, thanks.)
I have wondered wether the code conversion ability of qemu could be utilized to convert ELF .o object files compiled for i386 Linux by GCC to .o object files for ARM/Linux. Is this possible or has something been attempted in this direction?
Quoted 4 lines
The need for such conversion occurs when porting the Java MIDP to ARM. Due to export restrictions, for some cryptography code in the MIDP, only linkable object files for i386 are available with the sources. (Half a dozen small object files, clearly named like MD2.o MD5.o SHA1.o, ...).
The short answer is no,it's not possible.
In many cases it is possible to statically convert whole binaries from one arch to annother (http://www.complang.tuwien.ac.at/schani/bintrans/).
However in general it is not possible to convert a single object file/library then link it with native code. This would require inserting thunks on all the calls between native and translated code. To do this you need the full API used by the code. ie. what arguments are passed to each function, and how these arguments are used. C header files are not sufficient for this purpose by themselves.
To call non-native functions you need to use something like libffi
(http://sources.redhat.com/libffi/), possibly with descriptions autogenerated from source annotations.
It would be possible to manually write thunks for a particular interface, but it's a lot of work, and has to be redone for every interface.
Paul
Quoted 1 line · Paul Brook
On Tuesday 19 April 2005 10:10, Sebastian Nowozin wrote:
[snip]
Quoted 3 lines
Quoted 3 lines
I have wondered wether the code conversion ability of qemu could be utilized to convert ELF .o object files compiled for i386 Linux by GCC to .o object files for ARM/Linux.
[snip]
Quoted 4 lines
Quoted 1 line
(Half a dozen small object files, clearly named like MD2.o MD5.o SHA1.o, ...).
The short answer is no,it's not possible.
[snip]
Quoted 1 line
It would be possible to manually write thunks for a particular interface, but it's a lot of work, and has to be redone for every interface.
The even shorter answer is: Just do it.
For this particular library, with 6 to 10 particular _leaf_ (!!) functions (functions that don't call any other functions) whose calling sequence can be guessed, the translation is easy. Once you get to where qemu takes care of the tedious part (register and opcode mapping), the rest (inserting the relocation directives for access to a few static 'const' arrays) is easy.
Signature · 1 line
John Reiser, [email protected]
Quoted 10 lines · Sebastian Nowozin
Hello everybody,
(please quote my email address on a reply to this email, I am not member of the list, thanks.)
I have wondered wether the code conversion ability of qemu could be utilized to convert ELF .o object files compiled for i386 Linux by GCC to .o object files for ARM/Linux. Is this possible or has something been attempted in this direction?
Quoted 4 lines
The need for such conversion occurs when porting the Java MIDP to ARM. Due to export restrictions, for some cryptography code in the MIDP, only linkable object files for i386 are available with the sources. (Half a dozen small object files, clearly named like MD2.o MD5.o SHA1.o, ...).
Wouldn't it be easier to write your own crypto functions conform to the API used by the platform? All the algorithms you mention above are well documented.
Sincerely,
Bob Deblier