> >> But since you have to have a new gas anyway, wouldn't it be simpler > to > >> have > >> a new option for gas to instruct it to choose the opcodes that are > >> expected > >> by the win32 applications? > > This was my first idea, but Alexandre Julliard(the Wine maintainer) > disliked > > it and prefered a function attribute to turn it on per-function. I talked to Alexandre again, and his main concern wasn't so much the global flag, but that the existance of the push %ebp; mov %esp, %ebp was still up to the feelings of the compiler and the moon phase.
So what he wants is something like a msvc_prolog attribute that makes sure that the function starts with the following instructions and bytecode sequence, no matter what -fomit-frame-pointer and friends say: 8b ff mov.s %edi, %edi 55 push %ebp 8b ec mov.s %esp, %ebp So we basically need the msvc_prolog to add the "mov.s %edi, %edi" and force the frame pointer on, and make sure that this whole code is right at the beginning of the function(potentially conflicts with the stack alignment LEA) An alternative would be an ability to add custom assembler code to the start of each function, similarly to the __naked__ attribute, but probably with the constraint that the asm code is in total a nop, so the compiler still generates its own prolog. However, I have no idea how that could be implemented and fit into the C syntax, and it wouldn't be too nice wrt performance What will not really work is writing an __ASM_GLOBAL_FUNC that has the wrapper code and then calls or jmps to the real function. First of all that looks pretty ugly, and some windows software(copy protection mostly) doesn't like CALLs or JMPs(yes, these DRM systems often conflict with other DRM systems that install hooks or even rootkits) I'll try to come up with some proof of concept code later today.