Description
Many Linux users will have native x86-64 hardware, and we could use their CPU directly in the same way Rosetta worked, by using the processor's 32-bit compatibility mode.
In other words, the idea here is take the existing x86-64 Mac support and port it to Linux.
I tinkered a bit in this area here:
https://github.com/evmar/retrowin32/compare/linux?expand=1
Some notes:
-
that branch also has tinkering with 32-bit Linux which I think is less valuable because it would mean you need a 32-bit libc etc.
-
the LDT setup on Linux is different; the above branch has some syscally bits to at least print the LDT, but I'm not sure I got it right because I get back an empty array; on Mac my recollection there were entries in there already
-
on Mac I struggled a lot with how the binary gets laid out (see blog post); on Linux it appears the
-Ttext
linker flag lets you move the text section around and the heap is after that, which is great, but also it appears the first pages of the binary itself (like the file headers) get mapped at exactly 0x40_0000 on Linux which is exactly where Windows exes want to go; StackOverflow suggests this is hardcoded by the linker and we might need to use a linker script to avoid it
For most of this I think the answer will be roughly "dig through Wine to see how they did it".