Commit 6d217c32 by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/43293 (Invalid unwind info for i?86 -fpic)

	PR debug/43293
	* target.h (struct gcc_target): Add code_end hook.
	* target-def.h (TARGET_ASM_CODE_END): Define to hook_void_void
	if not yet defined.
	(TARGET_ASM_OUT): Add TARGET_ASM_CODE_END.
	* toplev.c (compile_file): Call targetm.asm_out.code_end
	hook before unwind info/debug info output.
	* config/i386/winnt.c (i386_pe_file_end): Don't call ix86_file_end.
	* config/i386/linux.h (NEED_INDICATE_EXEC_STACK): Don't define.
	(TARGET_ASM_FILE_END): Define to file_end_indicate_exec_stack.
	* config/i386/linux64.h (NEED_INDICATE_EXEC_STACK): Don't define.
	(TARGET_ASM_FILE_END): Define to file_end_indicate_exec_stack.
	* config/i386/i386.c (ix86_file_end): Renamed to...
	(ix86_code_end): ... this.  Make static.  Don't call
	file_end_indicate_exec_stack.  Emit unwind info using
	final_start_function/final_end_function.
	(darwin_x86_file_end): Remove.
	(TARGET_ASM_CODE_END): Define.
	* config/i386/i386.h (TARGET_ASM_FILE_END,
	NEED_INDICATE_EXEC_STACK): Don't define.
	* config/i386/darwin.h (darwin_x86_file_end): Remove prototype.
	(TARGET_ASM_FILE_END): Define to darwin_file_end.
	* config/i386/i386-protos.h (ix86_file_end): Remove prototype.
	* doc/tm.texi (TARGET_ASM_CODE_END): Document.

From-SVN: r157707
parent 81ef7e24
2010-03-24 Jakub Jelinek <jakub@redhat.com> 2010-03-24 Jakub Jelinek <jakub@redhat.com>
PR debug/43293
* target.h (struct gcc_target): Add code_end hook.
* target-def.h (TARGET_ASM_CODE_END): Define to hook_void_void
if not yet defined.
(TARGET_ASM_OUT): Add TARGET_ASM_CODE_END.
* toplev.c (compile_file): Call targetm.asm_out.code_end
hook before unwind info/debug info output.
* config/i386/winnt.c (i386_pe_file_end): Don't call ix86_file_end.
* config/i386/linux.h (NEED_INDICATE_EXEC_STACK): Don't define.
(TARGET_ASM_FILE_END): Define to file_end_indicate_exec_stack.
* config/i386/linux64.h (NEED_INDICATE_EXEC_STACK): Don't define.
(TARGET_ASM_FILE_END): Define to file_end_indicate_exec_stack.
* config/i386/i386.c (ix86_file_end): Renamed to...
(ix86_code_end): ... this. Make static. Don't call
file_end_indicate_exec_stack. Emit unwind info using
final_start_function/final_end_function.
(darwin_x86_file_end): Remove.
(TARGET_ASM_CODE_END): Define.
* config/i386/i386.h (TARGET_ASM_FILE_END,
NEED_INDICATE_EXEC_STACK): Don't define.
* config/i386/darwin.h (darwin_x86_file_end): Remove prototype.
(TARGET_ASM_FILE_END): Define to darwin_file_end.
* config/i386/i386-protos.h (ix86_file_end): Remove prototype.
* doc/tm.texi (TARGET_ASM_CODE_END): Document.
PR target/43498 PR target/43498
* config/i386/i386.c (x86_output_mi_thunk): Call final_start_function * config/i386/i386.c (x86_output_mi_thunk): Call final_start_function
at the beginning and final_end_function at the end. at the beginning and final_end_function at the end.
......
/* Target definitions for x86 running Darwin. /* Target definitions for x86 running Darwin.
Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008 Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2010
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Apple Computer Inc. Contributed by Apple Computer Inc.
...@@ -141,9 +141,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -141,9 +141,8 @@ along with GCC; see the file COPYING3. If not see
#define SHIFT_DOUBLE_OMITS_COUNT 0 #define SHIFT_DOUBLE_OMITS_COUNT 0
extern void darwin_x86_file_end (void);
#undef TARGET_ASM_FILE_END #undef TARGET_ASM_FILE_END
#define TARGET_ASM_FILE_END darwin_x86_file_end #define TARGET_ASM_FILE_END darwin_file_end
/* Define the syntax of pseudo-ops, labels and comments. */ /* Define the syntax of pseudo-ops, labels and comments. */
......
/* Definitions of target machine for GCC for IA-32. /* Definitions of target machine for GCC for IA-32.
Copyright (C) 1988, 1992, 1994, 1995, 1996, 1996, 1997, 1998, 1999, Copyright (C) 1988, 1992, 1994, 1995, 1996, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -27,7 +27,6 @@ extern void ix86_conditional_register_usage (void); ...@@ -27,7 +27,6 @@ extern void ix86_conditional_register_usage (void);
extern int ix86_can_use_return_insn_p (void); extern int ix86_can_use_return_insn_p (void);
extern void ix86_setup_frame_addresses (void); extern void ix86_setup_frame_addresses (void);
extern void ix86_file_end (void);
extern HOST_WIDE_INT ix86_initial_elimination_offset (int, int); extern HOST_WIDE_INT ix86_initial_elimination_offset (int, int);
extern void ix86_expand_prologue (void); extern void ix86_expand_prologue (void);
extern void ix86_expand_epilogue (int); extern void ix86_expand_epilogue (int);
......
...@@ -7580,8 +7580,8 @@ get_pc_thunk_name (char name[32], unsigned int regno) ...@@ -7580,8 +7580,8 @@ get_pc_thunk_name (char name[32], unsigned int regno)
/* This function generates code for -fpic that loads %ebx with /* This function generates code for -fpic that loads %ebx with
the return address of the caller and then returns. */ the return address of the caller and then returns. */
void static void
ix86_file_end (void) ix86_code_end (void)
{ {
rtx xops[2]; rtx xops[2];
int regno; int regno;
...@@ -7589,15 +7589,21 @@ ix86_file_end (void) ...@@ -7589,15 +7589,21 @@ ix86_file_end (void)
for (regno = 0; regno < 8; ++regno) for (regno = 0; regno < 8; ++regno)
{ {
char name[32]; char name[32];
#ifdef DWARF2_UNWIND_INFO tree decl;
bool do_cfi;
#endif
if (! ((pic_labels_used >> regno) & 1)) if (! ((pic_labels_used >> regno) & 1))
continue; continue;
get_pc_thunk_name (name, regno); get_pc_thunk_name (name, regno);
decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
get_identifier (name),
build_function_type (void_type_node, void_list_node));
DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL,
NULL_TREE, void_type_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
#if TARGET_MACHO #if TARGET_MACHO
if (TARGET_MACHO) if (TARGET_MACHO)
{ {
...@@ -7613,13 +7619,6 @@ ix86_file_end (void) ...@@ -7613,13 +7619,6 @@ ix86_file_end (void)
#endif #endif
if (USE_HIDDEN_LINKONCE) if (USE_HIDDEN_LINKONCE)
{ {
tree decl;
decl = build_decl (BUILTINS_LOCATION,
FUNCTION_DECL, get_identifier (name),
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl); DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl);
(*targetm.asm_out.unique_section) (decl, 0); (*targetm.asm_out.unique_section) (decl, 0);
...@@ -7637,23 +7636,22 @@ ix86_file_end (void) ...@@ -7637,23 +7636,22 @@ ix86_file_end (void)
ASM_OUTPUT_LABEL (asm_out_file, name); ASM_OUTPUT_LABEL (asm_out_file, name);
} }
#ifdef DWARF2_UNWIND_INFO DECL_INITIAL (decl) = make_node (BLOCK);
do_cfi = dwarf2out_do_cfi_asm (); current_function_decl = decl;
if (do_cfi) init_function_start (decl);
fprintf (asm_out_file, "\t.cfi_startproc\n"); /* Make sure unwind info is emitted for the thunk if needed. */
#endif final_start_function (emit_barrier (), asm_out_file, 1);
xops[0] = gen_rtx_REG (Pmode, regno); xops[0] = gen_rtx_REG (Pmode, regno);
xops[1] = gen_rtx_MEM (Pmode, stack_pointer_rtx); xops[1] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
output_asm_insn ("mov%z0\t{%1, %0|%0, %1}", xops); output_asm_insn ("mov%z0\t{%1, %0|%0, %1}", xops);
output_asm_insn ("ret", xops); output_asm_insn ("ret", xops);
#ifdef DWARF2_UNWIND_INFO final_end_function ();
if (do_cfi) init_insn_lengths ();
fprintf (asm_out_file, "\t.cfi_endproc\n"); free_after_compilation (cfun);
#endif set_cfun (NULL);
current_function_decl = NULL;
} }
if (NEED_INDICATE_EXEC_STACK)
file_end_indicate_exec_stack ();
} }
/* Emit code for the SET_GOT patterns. */ /* Emit code for the SET_GOT patterns. */
...@@ -25938,13 +25936,6 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub) ...@@ -25938,13 +25936,6 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub)
fprintf (file, "\t.indirect_symbol %s\n", symbol_name); fprintf (file, "\t.indirect_symbol %s\n", symbol_name);
fprintf (file, ASM_LONG "%s\n", binder_name); fprintf (file, ASM_LONG "%s\n", binder_name);
} }
void
darwin_x86_file_end (void)
{
darwin_file_end ();
ix86_file_end ();
}
#endif /* TARGET_MACHO */ #endif /* TARGET_MACHO */
/* Order the registers for register allocator. */ /* Order the registers for register allocator. */
...@@ -30550,6 +30541,9 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree) ...@@ -30550,6 +30541,9 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree)
#undef TARGET_CAN_ELIMINATE #undef TARGET_CAN_ELIMINATE
#define TARGET_CAN_ELIMINATE ix86_can_eliminate #define TARGET_CAN_ELIMINATE ix86_can_eliminate
#undef TARGET_ASM_CODE_END
#define TARGET_ASM_CODE_END ix86_code_end
struct gcc_target targetm = TARGET_INITIALIZER; struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-i386.h" #include "gt-i386.h"
...@@ -1627,9 +1627,6 @@ typedef struct ix86_args { ...@@ -1627,9 +1627,6 @@ typedef struct ix86_args {
#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
function_arg (&(CUM), (MODE), (TYPE), (NAMED)) function_arg (&(CUM), (MODE), (TYPE), (NAMED))
#define TARGET_ASM_FILE_END ix86_file_end
#define NEED_INDICATE_EXEC_STACK 0
/* Output assembler code to FILE to increment profiler label # LABELNO /* Output assembler code to FILE to increment profiler label # LABELNO
for profiling a function entry. */ for profiling a function entry. */
......
/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. /* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005, Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc. 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Contributed by Eric Youngdale. Contributed by Eric Youngdale.
Modified for stabs-in-ELF by H.J. Lu. Modified for stabs-in-ELF by H.J. Lu.
...@@ -202,8 +202,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -202,8 +202,7 @@ along with GCC; see the file COPYING3. If not see
#define LIBGCC2_TF_CEXT q #define LIBGCC2_TF_CEXT q
#define TF_SIZE 113 #define TF_SIZE 113
#undef NEED_INDICATE_EXEC_STACK #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
#define NEED_INDICATE_EXEC_STACK 1
#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h" #define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h"
......
/* Definitions for AMD x86-64 running Linux-based GNU systems with ELF format. /* Definitions for AMD x86-64 running Linux-based GNU systems with ELF format.
Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h. Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
...@@ -105,8 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -105,8 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBGCC2_TF_CEXT q #define LIBGCC2_TF_CEXT q
#define TF_SIZE 113 #define TF_SIZE 113
#undef NEED_INDICATE_EXEC_STACK #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
#define NEED_INDICATE_EXEC_STACK 1
#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h" #define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h"
......
/* Subroutines for insn-output.c for Windows NT. /* Subroutines for insn-output.c for Windows NT.
Contributed by Douglas Rupp (drupp@cs.washington.edu) Contributed by Douglas Rupp (drupp@cs.washington.edu)
Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -670,8 +670,6 @@ i386_pe_file_end (void) ...@@ -670,8 +670,6 @@ i386_pe_file_end (void)
{ {
struct extern_list *p; struct extern_list *p;
ix86_file_end ();
for (p = extern_head; p != NULL; p = p->next) for (p = extern_head; p != NULL; p = p->next)
{ {
tree decl; tree decl;
......
...@@ -7137,6 +7137,14 @@ need to do other things in that hook, have your hook function call ...@@ -7137,6 +7137,14 @@ need to do other things in that hook, have your hook function call
this function. this function.
@end deftypefun @end deftypefun
@deftypefn {Target Hook} void TARGET_ASM_CODE_END (void)
Output to @code{asm_out_file} any text which is needed before emitting
unwind info and debug info at the end of a file. Some targets emit
here PIC setup thunks that cannot be emitted at the end of file,
because they couldn't have unwind info then. The default is to output
nothing.
@end deftypefn
@defmac ASM_COMMENT_START @defmac ASM_COMMENT_START
A C string constant describing how to begin a comment in the target A C string constant describing how to begin a comment in the target
assembler language. The compiler assumes that the comment will end at assembler language. The compiler assumes that the comment will end at
......
/* Default initializers for a generic GCC target. /* Default initializers for a generic GCC target.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
...@@ -204,6 +204,10 @@ ...@@ -204,6 +204,10 @@
#define TARGET_ASM_FILE_END hook_void_void #define TARGET_ASM_FILE_END hook_void_void
#endif #endif
#ifndef TARGET_ASM_CODE_END
#define TARGET_ASM_CODE_END hook_void_void
#endif
#ifndef TARGET_EXTRA_LIVE_ON_ENTRY #ifndef TARGET_EXTRA_LIVE_ON_ENTRY
#define TARGET_EXTRA_LIVE_ON_ENTRY hook_void_bitmap #define TARGET_EXTRA_LIVE_ON_ENTRY hook_void_bitmap
#endif #endif
...@@ -292,6 +296,7 @@ ...@@ -292,6 +296,7 @@
TARGET_ASM_CAN_OUTPUT_MI_THUNK, \ TARGET_ASM_CAN_OUTPUT_MI_THUNK, \
TARGET_ASM_FILE_START, \ TARGET_ASM_FILE_START, \
TARGET_ASM_FILE_END, \ TARGET_ASM_FILE_END, \
TARGET_ASM_CODE_END, \
TARGET_ASM_EXTERNAL_LIBCALL, \ TARGET_ASM_EXTERNAL_LIBCALL, \
TARGET_ASM_MARK_DECL_PRESERVED, \ TARGET_ASM_MARK_DECL_PRESERVED, \
TARGET_ASM_RECORD_GCC_SWITCHES, \ TARGET_ASM_RECORD_GCC_SWITCHES, \
......
/* Data structure definitions for a generic GCC target. /* Data structure definitions for a generic GCC target.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
...@@ -235,6 +235,10 @@ struct gcc_target ...@@ -235,6 +235,10 @@ struct gcc_target
translation unit. */ translation unit. */
void (*file_end) (void); void (*file_end) (void);
/* Output any boilerplace text needed at the end of a
translation unit before debug and unwind info is emitted. */
void (*code_end) (void);
/* Output an assembler pseudo-op to declare a library function name /* Output an assembler pseudo-op to declare a library function name
external. */ external. */
void (*external_libcall) (rtx); void (*external_libcall) (rtx);
......
...@@ -1084,6 +1084,10 @@ compile_file (void) ...@@ -1084,6 +1084,10 @@ compile_file (void)
/* Write out any pending weak symbol declarations. */ /* Write out any pending weak symbol declarations. */
weak_finish (); weak_finish ();
/* This must be at the end before unwind and debug info.
Some target ports emit PIC setup thunks here. */
targetm.asm_out.code_end ();
/* Do dbx symbols. */ /* Do dbx symbols. */
timevar_push (TV_SYMOUT); timevar_push (TV_SYMOUT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment