summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-08 17:53:44 +0000
committerktietz <ktietz@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-08 17:53:44 +0000
commit2761b7cb0156763a66f84eabbba47751c2669577 (patch)
treefa8c8344ea79abfbf4515250a71acdceffc27b5d
parent7f55dd083b55f09bcc5940668f7d52780551e95c (diff)
downloadgcc-2761b7cb0156763a66f84eabbba47751c2669577.tar.gz
2010-07-08 Kai Tietz <kai.tietz@onevision.com>
* config/i386/i386-protos.h (ix86_asm_output_function_label): New prototype. * config/i386/i386.c (ix86_function_ms_hook_prologue): Check for NULL fntype argument and allow 64-bit targets. (ix86_asm_output_function_label): New function. (ix86_expand_prologue): Handle 64-bit ms hook prologue. (ix86_handle_fndecl_attribute): Likewise. * doc/extend.texi (ms_hook_prologue): Adjust documentation. * doc/doc/tm.texi: Regenerated. * doc/doc/doc/tm.texi.in (ASM_OUTPUT_FUNCTION_LABEL): New. (ASM_DECLARE_FUNCTION_NAME): Adjust documentation. * defaults.h (ASM_OUTPUT_FUNCTION_LABEL): New macro. * config/darwin.h (ASM_DECLARE_FUNCTION_NAME): Use ASM_OUTPUT_FUNCTION_LABEL instead of ASM_OUTPUT_LABEL. * config/elfos.h: Likewise. * config/i386/cygming.h: Likewise. * config/netbsd-aout.h: Likewise. * config/openbsd.h: Likewise. * config/i386/i386.h (ASM_OUTPUT_FUNCTION_LABEL): Override by ix86_asm_output_function_label function call. * varasm.c (assemble_start_function): Use ASM_OUTPUT_FUNCTION_LABEL instead of ASM_OUTPUT_LABEL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161971 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog25
-rw-r--r--gcc/config/darwin.h2
-rw-r--r--gcc/config/elfos.h2
-rw-r--r--gcc/config/i386/cygming.h2
-rw-r--r--gcc/config/i386/i386-protos.h1
-rw-r--r--gcc/config/i386/i386.c67
-rw-r--r--gcc/config/i386/i386.h7
-rw-r--r--gcc/config/netbsd-aout.h2
-rw-r--r--gcc/config/openbsd.h2
-rw-r--r--gcc/defaults.h10
-rw-r--r--gcc/doc/extend.texi8
-rw-r--r--gcc/doc/tm.texi17
-rw-r--r--gcc/doc/tm.texi.in17
-rw-r--r--gcc/varasm.c2
14 files changed, 127 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8d5962d2500..531729ce922 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,28 @@
+2010-07-08 Kai Tietz <kai.tietz@onevision.com>
+
+ * config/i386/i386-protos.h (ix86_asm_output_function_label):
+ New prototype.
+ * config/i386/i386.c (ix86_function_ms_hook_prologue): Check
+ for NULL fntype argument and allow 64-bit targets.
+ (ix86_asm_output_function_label): New function.
+ (ix86_expand_prologue): Handle 64-bit ms hook prologue.
+ (ix86_handle_fndecl_attribute): Likewise.
+ * doc/extend.texi (ms_hook_prologue): Adjust documentation.
+ * doc/doc/tm.texi: Regenerated.
+ * doc/doc/doc/tm.texi.in (ASM_OUTPUT_FUNCTION_LABEL): New.
+ (ASM_DECLARE_FUNCTION_NAME): Adjust documentation.
+ * defaults.h (ASM_OUTPUT_FUNCTION_LABEL): New macro.
+ * config/darwin.h (ASM_DECLARE_FUNCTION_NAME): Use
+ ASM_OUTPUT_FUNCTION_LABEL instead of ASM_OUTPUT_LABEL.
+ * config/elfos.h: Likewise.
+ * config/i386/cygming.h: Likewise.
+ * config/netbsd-aout.h: Likewise.
+ * config/openbsd.h: Likewise.
+ * config/i386/i386.h (ASM_OUTPUT_FUNCTION_LABEL): Override
+ by ix86_asm_output_function_label function call.
+ * varasm.c (assemble_start_function): Use
+ ASM_OUTPUT_FUNCTION_LABEL instead of ASM_OUTPUT_LABEL.
+
2010-07-08 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_will_be_removed_from_program_if_no_direct_calls):
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 6b681ee4509..99d99288152 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -651,7 +651,7 @@ extern GTY(()) int darwin_ms_struct;
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL)) \
(* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
- ASM_OUTPUT_LABEL (FILE, xname); \
+ ASM_OUTPUT_FUNCTION_LABEL (FILE, xname, DECL); \
} while (0)
#undef TARGET_ASM_DECLARE_CONSTANT_NAME
diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index 6818f6600fe..8c415bad442 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -282,7 +282,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
{ \
ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL (FILE, NAME); \
+ ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
} \
while (0)
#endif
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 470637644ff..1587af472cc 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -276,7 +276,7 @@ do { \
i386_pe_maybe_record_exported_symbol (DECL, NAME, 0); \
if (write_symbols != SDB_DEBUG) \
i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
- ASM_OUTPUT_LABEL (FILE, NAME); \
+ ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
} \
while (0)
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 696bb4a6cda..47a0a887d68 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -139,6 +139,7 @@ extern enum machine_mode ix86_fp_compare_mode (enum rtx_code);
extern rtx ix86_libcall_value (enum machine_mode);
extern bool ix86_function_arg_regno_p (int);
+extern void ix86_asm_output_function_label (FILE *, const char *, tree);
extern int ix86_function_arg_boundary (enum machine_mode, tree);
extern bool ix86_sol10_return_in_memory (const_tree,const_tree);
extern rtx ix86_force_to_memory (enum machine_mode, rtx);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 83bf4c114f7..99b4cc3e614 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5099,18 +5099,15 @@ ix86_function_type_abi (const_tree fntype)
static bool
ix86_function_ms_hook_prologue (const_tree fntype)
{
- if (!TARGET_64BIT)
+ if (fntype && lookup_attribute ("ms_hook_prologue", DECL_ATTRIBUTES (fntype)))
{
- if (lookup_attribute ("ms_hook_prologue", DECL_ATTRIBUTES (fntype)))
- {
- if (decl_function_context (fntype) != NULL_TREE)
- {
- error_at (DECL_SOURCE_LOCATION (fntype),
- "ms_hook_prologue is not compatible with nested function");
- }
+ if (decl_function_context (fntype) != NULL_TREE)
+ {
+ error_at (DECL_SOURCE_LOCATION (fntype),
+ "ms_hook_prologue is not compatible with nested function");
+ }
- return true;
- }
+ return true;
}
return false;
}
@@ -5133,6 +5130,40 @@ ix86_cfun_abi (void)
return cfun->machine->call_abi;
}
+/* Write the extra assembler code needed to declare a function properly. */
+
+void
+ix86_asm_output_function_label (FILE *asm_out_file, const char *fname,
+ tree decl)
+{
+ bool is_ms_hook = ix86_function_ms_hook_prologue (decl);
+
+ if (is_ms_hook)
+ {
+ int i, filler_count = (TARGET_64BIT ? 32 : 16);
+ unsigned int filler_cc = 0xcccccccc;
+
+ for (i = 0; i < filler_count; i += 4)
+ fprintf (asm_out_file, ASM_LONG " 0x%x\n", filler_cc);
+ }
+
+ ASM_OUTPUT_LABEL (asm_out_file, fname);
+
+ /* Output magic byte marker, if hot-patch attribute is set.
+ For x86 case frame-pointer prologue will be emitted in
+ expand_prologue. */
+ if (is_ms_hook)
+ {
+ if (TARGET_64BIT)
+ /* leaq [%rsp + 0], %rsp */
+ asm_fprintf (asm_out_file, ASM_BYTE
+ "0x48, 0x8d, 0xa4, 0x24, 0x00, 0x00, 0x00, 0x00\n");
+ else
+ /* movl.s %edi, %edi. */
+ asm_fprintf (asm_out_file, ASM_BYTE "0x8b, 0xff\n");
+ }
+}
+
/* regclass.c */
extern void init_regs (void);
@@ -9154,12 +9185,12 @@ ix86_expand_prologue (void)
ix86_compute_frame_layout (&frame);
- if (ix86_function_ms_hook_prologue (current_function_decl))
+ if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl))
{
rtx push, mov;
/* Make sure the function starts with
- 8b ff movl.s %edi,%edi
+ 8b ff movl.s %edi,%edi (emited by ix86_asm_output_function_label)
55 push %ebp
8b ec movl.s %esp,%ebp
@@ -9167,8 +9198,6 @@ ix86_expand_prologue (void)
functions in Microsoft Windows XP Service Pack 2 and newer.
Wine uses this to enable Windows apps to hook the Win32 API
functions provided by Wine. */
- insn = emit_insn (gen_vswapmov (gen_rtx_REG (SImode, DI_REG),
- gen_rtx_REG (SImode, DI_REG)));
push = emit_insn (gen_push (hard_frame_pointer_rtx));
mov = emit_insn (gen_vswapmov (hard_frame_pointer_rtx,
stack_pointer_rtx));
@@ -26976,15 +27005,9 @@ ix86_handle_fndecl_attribute (tree *node, tree name,
return NULL_TREE;
}
- if (TARGET_64BIT)
- {
- warning (OPT_Wattributes, "%qE attribute only available for 32-bit",
- name);
- return NULL_TREE;
- }
-
#ifndef HAVE_AS_IX86_SWAP
- sorry ("ms_hook_prologue attribute needs assembler swap suffix support");
+ if (!TARGET_64BIT)
+ sorry ("ms_hook_prologue attribute needs assembler swap suffix support");
#endif
return NULL_TREE;
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index d036bf03fec..eb3eb9f69b5 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2082,6 +2082,13 @@ do { \
}
#endif
+/* Write the extra assembler code needed to declare a function
+ properly. */
+
+#undef ASM_OUTPUT_FUNCTION_LABEL
+#define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
+ ix86_asm_output_function_label (FILE, NAME, DECL)
+
/* Under some conditions we need jump tables in the text section,
because the assembler cannot handle label differences between
sections. This is the case for x86_64 on Mach-O for example. */
diff --git a/gcc/config/netbsd-aout.h b/gcc/config/netbsd-aout.h
index 99e8c3a9c49..914212b877f 100644
--- a/gcc/config/netbsd-aout.h
+++ b/gcc/config/netbsd-aout.h
@@ -141,7 +141,7 @@ along with GCC; see the file COPYING3. If not see
{ \
ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL(FILE, NAME); \
+ ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
} \
while (0)
diff --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h
index 59728c377d6..30e1c252c5a 100644
--- a/gcc/config/openbsd.h
+++ b/gcc/config/openbsd.h
@@ -216,7 +216,7 @@ while (0)
do { \
ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL(FILE, NAME); \
+ ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
} while (0)
#endif
diff --git a/gcc/defaults.h b/gcc/defaults.h
index eb74033657b..e7e32c4dd06 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -133,13 +133,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif
/* This is how to output the definition of a user-level label named
- NAME, such as the label on a static function or variable NAME. */
+ NAME, such as the label on variable NAME. */
#ifndef ASM_OUTPUT_LABEL
#define ASM_OUTPUT_LABEL(FILE,NAME) \
do { assemble_name ((FILE), (NAME)); fputs (":\n", (FILE)); } while (0)
#endif
+/* This is how to output the definition of a user-level label named
+ NAME, such as the label on a function. */
+
+#ifndef ASM_OUTPUT_FUNCTION_LABEL
+#define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
+ ASM_OUTPUT_LABEL ((FILE), (NAME))
+#endif
+
/* Output the definition of a compiler-generated label named NAME. */
#ifndef ASM_OUTPUT_INTERNAL_LABEL
#define ASM_OUTPUT_INTERNAL_LABEL(FILE,NAME) \
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 967be9176ef..b9b4a44fd39 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2736,10 +2736,10 @@ the @option{-maccumulate-outgoing-args} option.
@item ms_hook_prologue
@cindex @code{ms_hook_prologue} attribute
-On 32 bit i[34567]86-*-* targets, you can use this function attribute to make
-gcc generate the "hot-patching" function prologue used in Win32 API
-functions in Microsoft Windows XP Service Pack 2 and newer. This requires
-support for the swap suffix in the assembler. (GNU Binutils 2.19.51 or later)
+On 32 bit i[34567]86-*-* targets and 64 bit x86_64-*-* targets, you can use
+this function attribute to make gcc generate the "hot-patching" function
+prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
+and newer.
@item naked
@cindex function without a prologue/epilogue code
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cb878afbe57..d3d9c1e8360 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -7661,6 +7661,19 @@ assembler syntax for defining the name, and a newline. A default
definition of this macro is provided which is correct for most systems.
@end defmac
+@defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl})
+A C statement (sans semicolon) to output to the stdio stream
+@var{stream} the assembler definition of a label named @var{name} of
+a function.
+Use the expression @code{assemble_name (@var{stream}, @var{name})} to
+output the name itself; before and after that, output the additional
+assembler syntax for defining the name, and a newline. A default
+definition of this macro is provided which is correct for most systems.
+
+If this macro is not defined, then the function name is defined in the
+usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+@end defmac
+
@findex assemble_name_raw
@defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name})
Identical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known
@@ -7744,11 +7757,11 @@ A C statement (sans semicolon) to output to the stdio stream
@var{stream} any text necessary for declaring the name @var{name} of a
function which is being defined. This macro is responsible for
outputting the label definition (perhaps using
-@code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the
+@code{ASM_OUTPUT_FUNCTION_LABEL}). The argument @var{decl} is the
@code{FUNCTION_DECL} tree node representing the function.
If this macro is not defined, then the function name is defined in the
-usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+usual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}).
You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
of this macro.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index bab073e5ae0..51a8e5eaeab 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -7660,6 +7660,19 @@ assembler syntax for defining the name, and a newline. A default
definition of this macro is provided which is correct for most systems.
@end defmac
+@defmac ASM_OUTPUT_FUNCTION_LABEL (@var{stream}, @var{name}, @var{decl})
+A C statement (sans semicolon) to output to the stdio stream
+@var{stream} the assembler definition of a label named @var{name} of
+a function.
+Use the expression @code{assemble_name (@var{stream}, @var{name})} to
+output the name itself; before and after that, output the additional
+assembler syntax for defining the name, and a newline. A default
+definition of this macro is provided which is correct for most systems.
+
+If this macro is not defined, then the function name is defined in the
+usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+@end defmac
+
@findex assemble_name_raw
@defmac ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{name})
Identical to @code{ASM_OUTPUT_LABEL}, except that @var{name} is known
@@ -7743,11 +7756,11 @@ A C statement (sans semicolon) to output to the stdio stream
@var{stream} any text necessary for declaring the name @var{name} of a
function which is being defined. This macro is responsible for
outputting the label definition (perhaps using
-@code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the
+@code{ASM_OUTPUT_FUNCTION_LABEL}). The argument @var{decl} is the
@code{FUNCTION_DECL} tree node representing the function.
If this macro is not defined, then the function name is defined in the
-usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+usual manner as a label (by means of @code{ASM_OUTPUT_FUNCTION_LABEL}).
You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
of this macro.
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 68ae70ac9b8..de78bd094c9 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1865,7 +1865,7 @@ assemble_start_function (tree decl, const char *fnname)
ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
#else
/* Standard thing is just output label for the function. */
- ASM_OUTPUT_LABEL (asm_out_file, fnname);
+ ASM_OUTPUT_FUNCTION_LABEL (asm_out_file, fnname, current_function_decl);
#endif /* ASM_DECLARE_FUNCTION_NAME */
}