This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Attachment: direction.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]