backport: re PR debug/40521 (-g causes GCC to generate .eh_frame)

Backport from mainline:
	2009-10-16  Jakub Jelinek  <jakub@redhat.com>

	PR debug/40521
	* debug.h (struct gcc_debug_hooks): Add assembly_start hook.
	* cgraphunit.c (cgraph_optimize): Call it.
	* dwarf2out.c (dwarf2out_init): Move .cfi_sections printing into...
	(dwarf2out_assembly_start): ... here.  New hook.
	(dwarf2out_debug_hooks): Add dwarf2out_assembly_start.
	* debug.c (do_nothing_debug_hooks): Do nothing for assembly_start
	hook.
	* dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise.
	* sdbout.c (sdb_debug_hooks): Likewise.
	* vmsdbgout.c (vmsdbg_debug_hooks): Add vmsdbgout_assembly_start.
	(vmsdbgout_assembly_start): New hook.

	2009-10-09  Jakub Jelinek  <jakub@redhat.com>

	PR debug/40521
	* dwarf2out.c (dwarf2out_init): Test whether
	HAVE_GAS_CFI_SECTIONS_DIRECTIVE is non-zero instead of checking
	it is defined.

	2009-10-02  Jakub Jelinek  <jakub@redhat.com>

	PR debug/40521
	* configure.ac (HAVE_GAS_CFI_SECTIONS_DIRECTIVE): New test.
	* configure: Regenerated.
	* config.in: Regenerated.
	* dwarf2out.c (dwarf2out_do_cfi_asm): Return false if
	!HAVE_GAS_CFI_SECTIONS_DIRECTIVE and not emitting .eh_frame.
	(dwarf2out_init): If HAVE_GAS_CFI_SECTIONS_DIRECTIVE and
	not emitting .eh_frame, emit .cfi_sections .debug_frame
	directive.

From-SVN: r152974
This commit is contained in:
Jakub Jelinek 2009-10-19 14:15:27 +02:00 committed by Jakub Jelinek
parent 38122002df
commit 82c7452fb9
11 changed files with 140 additions and 1 deletions

View File

@ -1,3 +1,40 @@
2009-10-19 Jakub Jelinek <jakub@redhat.com>
Backport from mainline:
2009-10-16 Jakub Jelinek <jakub@redhat.com>
PR debug/40521
* debug.h (struct gcc_debug_hooks): Add assembly_start hook.
* cgraphunit.c (cgraph_optimize): Call it.
* dwarf2out.c (dwarf2out_init): Move .cfi_sections printing into...
(dwarf2out_assembly_start): ... here. New hook.
(dwarf2out_debug_hooks): Add dwarf2out_assembly_start.
* debug.c (do_nothing_debug_hooks): Do nothing for assembly_start
hook.
* dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise.
* sdbout.c (sdb_debug_hooks): Likewise.
* vmsdbgout.c (vmsdbg_debug_hooks): Add vmsdbgout_assembly_start.
(vmsdbgout_assembly_start): New hook.
2009-10-09 Jakub Jelinek <jakub@redhat.com>
PR debug/40521
* dwarf2out.c (dwarf2out_init): Test whether
HAVE_GAS_CFI_SECTIONS_DIRECTIVE is non-zero instead of checking
it is defined.
2009-10-02 Jakub Jelinek <jakub@redhat.com>
PR debug/40521
* configure.ac (HAVE_GAS_CFI_SECTIONS_DIRECTIVE): New test.
* configure: Regenerated.
* config.in: Regenerated.
* dwarf2out.c (dwarf2out_do_cfi_asm): Return false if
!HAVE_GAS_CFI_SECTIONS_DIRECTIVE and not emitting .eh_frame.
(dwarf2out_init): If HAVE_GAS_CFI_SECTIONS_DIRECTIVE and
not emitting .eh_frame, emit .cfi_sections .debug_frame
directive.
2009-10-15 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
Backport from mainline

View File

@ -1293,6 +1293,7 @@ cgraph_optimize (void)
timevar_pop (TV_CGRAPHOPT);
/* Output everything. */
(*debug_hooks->assembly_start) ();
if (!quiet_flag)
fprintf (stderr, "Assembling functions:\n");
#ifdef ENABLE_CHECKING

View File

@ -839,6 +839,12 @@
#endif
/* Define 0/1 if your assembler supports .cfi_sections. */
#ifndef USED_FOR_TARGET
#undef HAVE_GAS_CFI_SECTIONS_DIRECTIVE
#endif
/* Define if your assembler uses the new HImode fild and fist notation. */
#ifndef USED_FOR_TARGET
#undef HAVE_GAS_FILDS_FISTS

36
gcc/configure vendored
View File

@ -21680,6 +21680,42 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
echo "$as_me:$LINENO: checking assembler for cfi sections directive" >&5
echo $ECHO_N "checking assembler for cfi sections directive... $ECHO_C" >&6
if test "${gcc_cv_as_cfi_sections_directive+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
gcc_cv_as_cfi_sections_directive=no
if test x$gcc_cv_as != x; then
echo ' .text
.cfi_sections .debug_frame, .eh_frame
.cfi_startproc
.cfi_endproc' > conftest.s
if { ac_try='$gcc_cv_as -o conftest.o conftest.s >&5'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }
then
gcc_cv_as_cfi_sections_directive=yes
else
echo "configure: failed program was" >&5
cat conftest.s >&5
fi
rm -f conftest.o conftest.s
fi
fi
echo "$as_me:$LINENO: result: $gcc_cv_as_cfi_sections_directive" >&5
echo "${ECHO_T}$gcc_cv_as_cfi_sections_directive" >&6
cat >>confdefs.h <<_ACEOF
#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE `if test $gcc_cv_as_cfi_sections_directive = yes;
then echo 1; else echo 0; fi`
_ACEOF
# GAS versions up to and including 2.11.0 may mis-optimize
# .eh_frame data.
echo "$as_me:$LINENO: checking assembler for eh_frame optimization" >&5

View File

@ -2297,6 +2297,17 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_PERSONALITY_DIRECTIVE,
then echo 1; else echo 0; fi`],
[Define 0/1 if your assembler supports .cfi_personality.])
gcc_GAS_CHECK_FEATURE([cfi sections directive],
gcc_cv_as_cfi_sections_directive, ,,
[ .text
.cfi_sections .debug_frame, .eh_frame
.cfi_startproc
.cfi_endproc])
AC_DEFINE_UNQUOTED(HAVE_GAS_CFI_SECTIONS_DIRECTIVE,
[`if test $gcc_cv_as_cfi_sections_directive = yes;
then echo 1; else echo 0; fi`],
[Define 0/1 if your assembler supports .cfi_sections.])
# GAS versions up to and including 2.11.0 may mis-optimize
# .eh_frame data.
gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame,

View File

@ -349,6 +349,7 @@ const struct gcc_debug_hooks dbx_debug_hooks =
{
dbxout_init,
dbxout_finish,
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
dbxout_start_source_file,
@ -385,6 +386,7 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
{
dbxout_init,
dbxout_finish,
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
dbxout_start_source_file,

View File

@ -27,6 +27,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
{
debug_nothing_charstar,
debug_nothing_charstar,
debug_nothing_void,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
debug_nothing_int_charstar,

View File

@ -31,6 +31,10 @@ struct gcc_debug_hooks
/* Output debug symbols. */
void (* finish) (const char *main_filename);
/* Called from cgraph_optimize before starting to assemble
functions/variables/toplevel asms. */
void (* assembly_start) (void);
/* Macro defined on line LINE with name and expansion TEXT. */
void (* define) (unsigned int line, const char *text);

View File

@ -145,7 +145,18 @@ dwarf2out_do_cfi_asm (void)
#endif
if (!flag_dwarf2_cfi_asm || !dwarf2out_do_frame ())
return false;
if (saved_do_cfi_asm || !eh_personality_libfunc)
if (saved_do_cfi_asm)
return true;
if (!HAVE_GAS_CFI_SECTIONS_DIRECTIVE)
{
#ifdef TARGET_UNWIND_INFO
return false;
#else
if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
return false;
#endif
}
if (!eh_personality_libfunc)
return true;
if (!HAVE_GAS_CFI_PERSONALITY_DIRECTIVE)
return false;
@ -4583,6 +4594,7 @@ static int output_indirect_string (void **, void *);
static void dwarf2out_init (const char *);
static void dwarf2out_finish (const char *);
static void dwarf2out_assembly_start (void);
static void dwarf2out_define (unsigned int, const char *);
static void dwarf2out_undef (unsigned int, const char *);
static void dwarf2out_start_source_file (unsigned, const char *);
@ -4605,6 +4617,7 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
{
dwarf2out_init,
dwarf2out_finish,
dwarf2out_assembly_start,
dwarf2out_define,
dwarf2out_undef,
dwarf2out_start_source_file,
@ -16187,6 +16200,22 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
switch_to_section (cold_text_section);
ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
}
}
/* Called before cgraph_optimize starts outputtting functions, variables
and toplevel asms into assembly. */
static void
dwarf2out_assembly_start (void)
{
if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE && dwarf2out_do_cfi_asm ())
{
#ifndef TARGET_UNWIND_INFO
if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
#endif
fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
}
}
/* A helper function for dwarf2out_finish called through

View File

@ -307,6 +307,7 @@ const struct gcc_debug_hooks sdb_debug_hooks =
{
sdbout_init, /* init */
sdbout_finish, /* finish */
debug_nothing_void, /* assembly_start */
debug_nothing_int_charstar, /* define */
debug_nothing_int_charstar, /* undef */
sdbout_start_source_file, /* start_source_file */

View File

@ -166,6 +166,7 @@ static int write_srccorrs (int);
static void vmsdbgout_init (const char *);
static void vmsdbgout_finish (const char *);
static void vmsdbgout_assembly_start (void);
static void vmsdbgout_define (unsigned int, const char *);
static void vmsdbgout_undef (unsigned int, const char *);
static void vmsdbgout_start_source_file (unsigned int, const char *);
@ -188,6 +189,7 @@ static void vmsdbgout_abstract_function (tree);
const struct gcc_debug_hooks vmsdbg_debug_hooks
= {vmsdbgout_init,
vmsdbgout_finish,
vmsdbgout_assembly_start,
vmsdbgout_define,
vmsdbgout_undef,
vmsdbgout_start_source_file,
@ -1635,6 +1637,15 @@ vmsdbgout_init (const char *main_input_filename)
/* Not implemented in VMS Debug. */
static void
vmsdbgout_assembly_start (void)
{
if (write_symbols == VMS_AND_DWARF2_DEBUG)
(*dwarf2_debug_hooks.assembly_start) ();
}
/* Not implemented in VMS Debug. */
static void
vmsdbgout_define (unsigned int lineno, const char *buffer)
{