This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: Add support for the Win32 hook prologue (try 3)


Am Friday 11 September 2009 21:58:41 schrieb Richard Henderson:
> In which case, hooking into ASM_DECLARE_FUNCTION_NAME will be
> tricky, but doable.  You may want to follow the lead of
> ASM_DECLARE_RESULT in elfos.h and define a normally empty
> macro you can override in i386 generic code.
I am working on this right now(compiling atm...). Do I understand this 
correctly: Basically, I can add the 5 nops in ASM_DECLARE_FUNCTION_NAME, 
kinda in this way:

i386.h:
#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
  ix86_asm_declare_function_name(FILE,NAME,DECL);

i386.c:
void ix86_asm_declare_function_name (FILE *file, const char *fnname, tree 
decl) {
    if (/* ix86_function_ms_hook_prologue (TREE_TYPE (decl)) */ 1) {
        gen_nop(); gen_nop(); gen_nop(); gen_nop(); gen_nop();
    }
    ASM_OUTPUT_LABEL (file, fnname);
}

(Slightly compacted code style for the mail). I haven't gotten the 
ms_hook_prologue check working yet - in the way I put it there I get some 
error about wrong tree types.

However, files like cygming.h define their own ASM_DECLARE_FUNCTION_NAME, so 
they'll overwrite the one in i386.h. Did I understand this correctly so far?

So, you propose a solution like this:
in i386.h
#define IX86_ADD_HOOK_NOPS ix86_hook_nops;

#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
  IX86_ADD_HOOK_NOPS(FILE, DECL) \
  ix86_asm_declare_function_name(FILE,NAME,DECL);

i386.c:
void ix86_asm_declare_function_name (FILE *file, const char *fnname, tree 
decl) { ASM_OUTPUT_LABEL }
void ix86_hook_nops(FILE *file, tree decl) {
	if(ms_hook_prologue) {
		gen_nop(), gen_nop(), gen_nop();
	}
}

And in cygming.h and other places that have their own 
ASM_DECLARE_FUNCTION_NAME:
#ifndef IX86_ADD_HOOK_NOPS
#define IX86_ADD_HOOK_NOPS(file, decl)
#endif

#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
   IX86_ADD_HOOK_NOPS(FILE, DECL) \
   whatever_declare_function_exists(file, name, decl)

At which places do I have to do that? config/i386/cygming.h? Or also things 
like config/darwin.h?

Also, it I guess its a good idea to split the in-function two byte nop and the 
nops before the function into two different patches. (Maybe the outer nops 
first, then the things inside the function)


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