Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a library containing numerous *.o files. These are files that were written by a coworker some time back and the source code has since been lost. They work fine with my current linux distro but I'd like to use these on another platform.
These files are compiled for elf32-i386 architecture. What I'd like to do is make them work on an ARM platform which requires they be elf32-littlearm. Is there any hope of doing this? (I basically used objdump to figure out the architectures and tried to use objcopy to convert them)
I'd rather not rewrite the code as it took this guy quite some time to get all the bugs out and quite frankly, I don't think I could recreate what he did.
That the command I've been really trying to figure out. I've got two versions of the command, one that comes stock with my distro, the other came with the ARM system I'm using.
I can't do a straight conversion from elf32-i386 to elf32-littlearm because the standard objcopy doesn't support the arm architecture. So I've to use the standard objcopy to convert to elf32-little and then the other objcopy to convert that to elf32-littlearm
The problem is that the standard objcopy returns with a segmentation fault with the following command
My next thought was to convert to binary first and then binary to elf32-little, but that failed as well. the commands ran, but the output files were not any good (i.e. all the symbol info was gone).
I've considered decompilers as well, but the only that looked promising (boomerang) and worked on other code did not work on this code (I think it only works on c, not c++). I've not found any other decompilers that would work.
So yes, I think objcopy is the way to go, I just can't get it to do what I want. I've also tried the 'strip' command but had similar results.
It may just be that I'm not understanding the commands so any other input on objcopy to meat this end would be welcome.
Unlikely. The instruction set for the i386 CPU is different from the ARM CPU. Disassembly of object code will only get you assembler code for the '368. Converting that to ARM assembly code will be significantly difficult. The easiest solution to the OP's problem is probably to re-write from scratch.
The file format of the object code is only a small part of the compatibility issue.
--- rod.
ok, so the difference between the architectures is not just a format thing, but an instruction set thing as well?
That makes sense when I step back and think about it. I was hoping it would be a matter of simply rearranging bits but if I've also to interpret the varying commands, it probably would be better to just do a rewrite.
As I played around with this, I've made some good progress for c code (as opposed to c++) on this end. I've been able to use a decompiler to get c files of a 386 'o' file and then recompile it using my arm cross compiler. However, the o files I've got are c++ I've determined, so without a c++ decompiler, I'll be stuck with a rewrite I think.
Thanks for the tips, if theres any other ideas let me know, this is one of the problems that is fun to play with.
That is right. If it were any other way, we would not need cross compilers. The beauty of Java is that it does run java bytecode on any platform, as long as it has a Java virtual machine to run it.
--- rod.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.