Executing a Linux Generated file
Brian Inglis
Brian.Inglis@SystematicSW.ab.ca
Tue Sep 1 19:50:14 GMT 2026
On 2026-09-01 13:00, Arthur Schwarz via Cygwin wrote:
>
> On 9/1/2026 11:46 AM, Eliot Moss wrote:
>> On 9/1/2026 2:18 PM, Takashi Yano via Cygwin wrote:
>>> On Tue, 1 Sep 2026 10:54:18 -0700
>>> Arthur Schwarz via Cygwin <cygwin@cygwin.com> wrote:
>>>
>>>> Using cygwin, is there any way to execute a Linux executable, as in:
>>>>
>>>> > ./linux.exe
>>>
>>> If by ‘Linux executable’ you mean an ELF executable file,
>>> the answer is no. You have to rebuild the program from
>>> source in Cygwin.
>>
>> At its heart, cygwin is a Windows *library* file, cygwin.dll, that
>> you link with a program compiled and linked using cygwin tools,
>> which run under Windows. You get a Windows executable whose
>> library API mimics POSIX as closely as possible under Windows.
>>
>> To run true Linux executables, you need a Linux virtual machine,
>> such as Windows Subsystem for Linux, Oracle, or VMWare. For some
>> purposes qemu also works for that.
>>
>> I use all three, that is, Windows, cygwin with many command line (bash)
>> and X windows GUI programs, and WSL, each for its own purposes. I have
>> also gotten good mileage from Oracle VMs and such in the past.
>>
>> Regards - Eliot Moss
>
> Thank Eliot;
>
> My thought was that the Linux executable (ELO code?) can be reorganized to
> duplicate the load code for a Windows machine, and that then the Windows machine
> is presented with acceptable code. Something like:
>
> Unix Executable -> cygwin reformatting -> Windows executable -> execute
>
> Without the need to recompile the code under a cygwin framework (or a Windows
> framework).
>
> My thought was that it would be possible to reinterpret the Unix load code,
> reformat it and generate a Windows .exe file, and that someone has already done
> this and, perhaps, made it 'part of' the bash shell. Apparently this can not be
> done.
>
> Basically, load code is load code. The needs to load code in on OS are the same
> needs in another, and although the format of the load code is different between
> OSs, the needs are the same and that one format can be converted to another. In
> a different context gcc (the GNU compiler set) has a similar problem and solves
> it by converting the input language to some generic internal format which is
> reformatted depending on the target computer (a few steps are left out here).
> Given this it seemed to me that a similar, but easier, issue would be involved
> for load formats. Unfortunately I appear to be wrong.
To run Linux x86_64 ELF executables, the OS or some emulation layer has to load
the executable into memory, setting the permissions and protections for each
type of code and data section, mapping, loading, and linking Linux x86_64 ELF
shared libraries in most cases, and starting execution.
Ultimately, Linux executables execute Linux x86_64 syscalls to enter the OS:
without WSL to handle those, or some other VM, Windows will fault or even BSOD,
similar to issues caused by poor AntiVirus software or malware.
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher but when there is no more to cut
-- Antoine de Saint-Exupéry
More information about the Cygwin
mailing list