I mean could a single binary file run in both Win32 and Linux i386 ?
相关问题
- Is shmid returned by shmget() unique across proces
- the application was unable to start correctly 0xc0
- how to get running process information in java?
- Handle button click in another application
- Error building gcc 4.8.3 from source: libstdc++.so
The two formats are sufficiently different that a hybrid is unlikely.
However, Linux supports loading different executable formats by "interpreter". This way compiled
.exe
files containing CIL (compiled C# or other .NET languages) can be executed directly under Linux, for example.This is not possible, because the two types have conflicting formats:
'M' 'Z'
;'\x7f' 'E' 'L' 'F'
.Clearly, you can't create one file that satisifies both formats.
In response to the comment about a polyglot binary valid as both a 16 bit COM file and a Linux ELF file, that's possible (although really a COM file is a DOS program, not Windows - and certainly not Win32).
Here's one I knocked together - compile it with NASM. It works because the first two bytes of an ELF file (
'\x7f' 'E'
) happen to also be valid 8086 machine code (a 45 byte relative jump-if-greater-than instruction). Minimal ELF headers cribbed from Brian Raiter.Sure. Use Java.