Feature request: Set the direction flag on x86/x64 register->register operations

Stefan Dösinger stefan@codeweavers.com
Tue Nov 25 12:25:00 GMT 2008


Hello,

I have a patch attached for discussion that adds an option to make gas set
the direction inversion flag on register to register operation. The main
intended effect is that "mov %esp, %ebp" is assembled to "8b ec" instead of
"89 e5".

I am working on Wine, a software to run unmodified Windows Applications on
Linux and other Unixes(www.winehq.org). We use gcc and gas to compile our
replacement DLLs. There are a few popular applications like Steam or
Teamspeak that attempt to inject some of their code into other Win32
processes by hooking Win32 API calls by modifying the first 5 bytes of the
function. Usually those 5 bytes look like this on Windows:

8b ff		mov %edi, %edi
55		push %ebp
8b ec		mov %esp, %ebp

My problem is that those apps do not know the "89 e5" gas generates, as the
apps are quite stubborn. (The mov %edi, %edi is something I have to fix in
gcc).

I have attached a patch that adds an option to the assembler to generate
Windows-Style opcodes. I don't know if it is ready to be committed as-is,
but I have a few questions:

Is such a feature acceptable at all, or should I maintain this in my private
builds?

Is this safe? So far I haven't run the gas testsuite yet

The code change seems ugly to me, I don't like the way the code changes the
indices. I am not familiar with the structures there, so I don't see any way
to make it look nicer

Thanks for your help,
Stefan Dösinger

-------------- next part --------------
A non-text attachment was scrubbed...
Name: direction.diff
Type: application/octet-stream
Size: 5919 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20081125/af9b5d57/attachment.obj>


More information about the Binutils mailing list