RE: Feature request concerning opcodes in the function prolog

2009-01-12 Thread amylaar
Quoting Stefan Dösinger : Here's some code attached that actually works, but is far from perfect. The 'msvc_prologue' attribute is limited to 32 bit. None of the applications that try to place hooks are ported to Win64 yet, so it is impossible to tell what they'll need. Besides, maybe I am luck

Re: Feature request concerning opcodes in the function prolog

2009-01-12 Thread Paolo Bonzini
> For my purposes it is not really suitable, because we have to make sure that > the push %ebp and mov %esp, %ebp are there, no matter what the compiler > arguments are(-fomit-frame-pointer). So just adding the mov %edi, %edi isn't > enough, and while I'm at it I can add the .s to the insns anyway.

RE: Feature request concerning opcodes in the function prolog

2009-01-12 Thread Stefan Dösinger
> Have you thought about making .s an assembler command-line flag, so > that > this flag could be passed automatically by the compiler under mingw? Yes. For my purposes it is not really suitable, because we have to make sure that the push %ebp and mov %esp, %ebp are there, no matter what the compi

Re: Feature request concerning opcodes in the function prolog

2009-01-12 Thread Paolo Bonzini
> movl.s %edi, %edi > pushl %ebp > movl.s %esp, %ebp Have you thought about making .s an assembler command-line flag, so that this flag could be passed automatically by the compiler under mingw? Paolo

RE: Feature request concerning opcodes in the function prolog

2009-01-12 Thread Stefan Dösinger
Here's some code attached that actually works, but is far from perfect. The 'msvc_prologue' attribute is limited to 32 bit. None of the applications that try to place hooks are ported to Win64 yet, so it is impossible to tell what they'll need. Besides, maybe I am lucky that when they appear I can

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread Stefan Dösinger
> If ebp needs to be saved because it contains a user variable, it is > better > not to pop it in the prologue - pop it in the epilogue instead, and you > don't > need to have another save/restore. Sounds reasonable. Is there any flag I can set to make the epilogue pop ebp? > This can be done wit

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread amylaar
Quoting Stefan Dösinger : If the frame pointer is not needed: mov.s %edi, %edi push %ebp mov.s %esp, %ebp pop %ebp ; Continue normally here. I think that case can't be improved too much, since the msvc_prolog stuff modifies the base pointer. If ebp needs to be saved because it contains a use

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread Stefan Dösinger
> You don't need to force the frame pointer on, it is sufficient to say > that > ebp needs restoring at the end of the function no matter if it looks > otherwise > used or not - and you have to take the frame size impact of the saved > ebp into > account. How does this fit together with the stack

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread amylaar
Quoting Stefan Dösinger : 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 ma

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread Stefan Dösinger
> >> 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

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread Joern Rennecke
Quoting Stefan Dösinger : 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 prefer

RE: Feature request concerning opcodes in the function prolog

2009-01-08 Thread Joern Rennecke
Quoting Stefan Dösinger : 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 prefer

Re: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Paolo Bonzini
>> 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 funct

RE: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Stefan Dösinger
> An example of an unspec_volatile instruction pattern in > config/i386/i386.md > is "cld". I ran across that, your hints should give me some information to chew on for the next hours. Currently I am compiling with this code to see what happens: (define_insn "movnop" [(unspec_volatile [(const_int

RE: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Joern Rennecke
Quoting Stefan Dösinger : 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 '*',

RE: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Stefan Dösinger
> You can make a new instruction pattern with an UNSPEC_VOLATILE pattern. > For a quick prototype you could also use an assembler prologue, > although > if you need not experiment with different insn sequences, this will > likely > be more work in the long run if/when assembler prologues are eventu

Re: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Joern Rennecke
The attached file gcc.diff contains a kinda helpless attempt to generate this instruction. My first problem is that any optimization optimizes it away because it is a NOP. Is there any way to prevent the optimizer from removing it? You can make a new instruction pattern with an UNSPEC_VOLATILE p

RE: Feature request concerning opcodes in the function prolog

2009-01-07 Thread Stefan Dösinger
> -Original Message- > From: H.J. Lu [mailto:hjl.to...@gmail.com] Nice to see a familiar face, or better, mail address :-) > You need to check assembler feature with autconf before using them. > See HAVE_AS_IX86_SAHF as example. Thanks! Does that look ok? It seems to detect the support

Re: Feature request concerning opcodes in the function prolog

2009-01-07 Thread H.J. Lu
On Wed, Jan 7, 2009 at 10:05 AM, Stefan Dösinger wrote: > > I talked to the binutils maintainers and they helped me by adding a new > instruction suffix .s: > movl%esp, %ebp => 89 e5 > movl.s %esp, %ebp => eb ec > > Now I need gcc to set this suffix, but here I am pretty lost. I haven't

Feature request concerning opcodes in the function prolog

2009-01-07 Thread Stefan Dösinger
Hello, I am working on the Wine project(www.winehq.org), which (obviously) uses gcc to compile its own code. There are some Windows applications like Steam(www.steampowered.com) and others which try to hook Win32 API functions by patching the first 5 bytes of the Windows API functions exported by