On 11/24/24 01:21, Pierrick Bouvier wrote:
After thinking about it, a simple, exhaustive and reliable way to find
this type information is the debug (dwarf) info.
By compiling qemu binaries with --enable-debug, and extracting info
using llvm-dwarfdump plus a custom filter [4], we can obtain a text
representation of all structures QEMU uses.
Yes, this is a good idea.
As there is a lot of repetition between all qemu binaries, the reduced
list of structs concerned is [6]:
+name:ArduinoMachineClass size:0x0198
+name:ARMCacheAttrs size:0x04
+name:ARMVAParameters size:0x04
+name:AspeedMachineClass size:0x01d0
+name:_GIOChannel size:0x70
This one unfortunately shows why the global change is wrong. The size
of _GIOChannel must match between glib and QEMU, otherwise you have an
ABI mismatch.
In other words, the global default _must_ be -mms-bitfields, because all
other libraries (and also Windows itself, though you didn't find any
occurrences) are built with MSVC ABI compatibility. Bitfields are
relatively rare, and therefore you only found one occurrence; however,
this is a constraint that we cannot get rid of.
However, your script lets you do the opposite experiment: remove
gcc_struct QEMU_PACKED and check if anything changes, i.e. whether there
are any QEMU_PACKED structs that do rely on the gcc_struct attribute.
If there are any, then it should be possible to change the definition
and fix them.
Thanks,
Paolo