FEX-Emu / FEX

A fast usermode x86 and x86-64 emulator for Arm64 Linux
https://fex-emu.com
MIT License
2.09k stars 115 forks source link

Implement libc thunk library #1505

Open neobrain opened 2 years ago

neobrain commented 2 years ago

Thunking libc itself has the potential to make thunking other libraries significantly more robust by making various workarounds unnecessary (see #1208). Here's an (incomplete) list of nontrivial things that need to be tackled:

neobrain commented 2 years ago

errno handling

errno is a data symbol exported by libc.so, written to by many (but not all) libc functions on error (and written to by guest application to "reset" errors). When thunking libc, the problem that arises is that the errno symbol exposed by thunked libc to guest applications is a different symbol than the native errno symbol that host libc functions write to. Unless we find magic to allow for sharing the same data symbol, some mechanism to synchronize the value between the two data symbols is needed.

A lot of functions set errno, so a scalable approach is needed for synchronizing the native/thunk errno values. Here are some potential options to handle this: