Hi,
Il 19/08/21 17:08, Erich E. Hoover ha scritto:
- 32-bit system libraries are being deprecated by the distros (and
Apple has already discontinued 32-bit support), so converting built-in libraries to PE means that Wine will interface solely with the 64-bit system libraries.
My understanding is that this is not just 32 on 64, but can be useful in general to run any architecture inside any other, with the help of an emulator. Given that ARM already has virtually all mobile devices and it is cutting itself a corner even among laptops and desktops, that could eventually become something we want to do. Arguably, it is already.
As I get it, the main idea here is that PE libraries are meant to be ran in the guest architecture and ELF libraries are meant to be ran in the host architecture. Of course the two must speak to each other, and this happens through a well defined interface, where it is (relatively) easy to do what the two architectures require to understand each other (enter or leave the emulator, change processor mode, convert pointers, endianness, sizes, whatever). In particular, PE modules do not need and cannot interface directly with the operating system's libraries.
For PE libraries that do not need to interface with host libraries, there is little to be done. For PE libraries that have to talk with the host system, they need a corresponding ELF library (which is just a regular host ELF library, so can link against other host libraries at its will). When the PE module is loaded, it calls __wine_init_unix_lib, which is intercepted by ntdll, which loads the corresponding ELF library and calls its __wine_init_unix_lib function, which returns a point to a structure with all the function pointers that the PE library might want to call. Given that ntdll mediates this exchange, it will be able to do whatever thunking is required to make the interface between the two worlds work.
I've heard of a syscall-like mechanism, but I am not sure it is relevant here.
This is what I could understand of this business. I'm happy to take corrections for whatever I mistook.
Giovanni.