Quoting Stefan Dösinger <ste...@codeweavers.com>:

Thanks for the hint - I'll see what I can find. Do you have any hints for
good examples in the existing code?

An example of an unspec_volatile instruction pattern in config/i386/i386.md
is "cld".  Note that by giving the pattern a name which is not prefixed with
'*', a generator function will be emitted when you build gcc (gen_cld for the
cld example; it is used in i386.md).

For examples of assembler prologues, grep config/*/*.c for
TARGET_ASM_FUNCTION_PROLOGUE .
Note that you can have both an asm prologue and an rtl prologue, which
is ugly, but flexible ;-)

Ideally I'd like to set this suffix on all instructions in a function(gas
ignores the suffix on instrs that don't support it). I'll probably survive
if this is just set on the mov %edi, %edi and mov %esp, %ebp. But
unfortunately not all functions apps try to hook have the mov %edi, %edi,
but apps still try to hook them. This means that 2 bytes remain problematic,
and on those there's often a xor %eax, %eax (which is either 31 c0 or 33 c0)
or a sub modifying the stack pointer. So the problem potentially goes beyond
the prologue.

gcc has the concept of assembler dialects, where you can have different
syntax depending on an invocation option; or you could use some
% directive in the assembler template to emit - or not emit - a suffix.
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?
Or do they require different opcodes for the same instruction in different places, e.g an 8bec movl esp,ebp in the prologue and a 89e5 movl esp,ebp for address arithmetic in an -fomit-frame-pointer (or the moral equivalent) compiled function?

Reply via email to