diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 70 | ||||
-rw-r--r-- | gcc/except.c | 40 | ||||
-rw-r--r-- | gcc/output.h | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20051207-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20051207-2.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20051207-3.c | 7 | ||||
-rw-r--r-- | gcc/varasm.c | 19 |
9 files changed, 105 insertions, 70 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe7abdcbe2f..f6218980471 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2005-12-10 Richard Sandiford <richard@codesourcery.com> + + * dwarf2out.c (default_eh_frame_section): Delete, moving handling + of EH_FRAME_SECTION_NAME into... + (switch_to_eh_frame_section): ...here. Try to set eh_frame_section + if it is still null. + * except.c (default_exception_section): Delete, moving most + of the code to... + (switch_to_exception_section): ...this new function. Set + exception_section if it is still null, then switch to it. + (output_function_exception_table): Use switch_to_exception_section. + * varasm.c (exception_section, eh_frame_section): Update comments. + (get_section): Hoist use of SECTION_NAMED. + (init_varasm_once): Don't set exception_section and eh_frame_section. + * output.h (default_exception_section): Delete. + (default_eh_frame_section): Delete. + 2005-12-09 Bernd Schmidt <bernd.schmidt@analog.com> * config/bfin/bfin.c: Include "cgraph.h". diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index ba7ce834edd..0f52184cd61 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -113,42 +113,6 @@ dwarf2out_do_frame (void) #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT) #endif -/* Return the default value of eh_frame_section. Note that this function - must appear outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO - macro guards. */ - -section * -default_eh_frame_section (void) -{ -#ifdef EH_FRAME_SECTION_NAME - int flags; - - if (EH_TABLES_CAN_BE_READ_ONLY) - { - int fde_encoding; - int per_encoding; - int lsda_encoding; - - fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0); - per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1); - lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0); - flags = (! flag_pic - || ((fde_encoding & 0x70) != DW_EH_PE_absptr - && (fde_encoding & 0x70) != DW_EH_PE_aligned - && (per_encoding & 0x70) != DW_EH_PE_absptr - && (per_encoding & 0x70) != DW_EH_PE_aligned - && (lsda_encoding & 0x70) != DW_EH_PE_absptr - && (lsda_encoding & 0x70) != DW_EH_PE_aligned)) - ? 0 : SECTION_WRITE; - } - else - flags = SECTION_WRITE; - return get_section (EH_FRAME_SECTION_NAME, flags, NULL); -#else - return NULL; -#endif -} - DEF_VEC_P(rtx); DEF_VEC_ALLOC_P(rtx,gc); @@ -1992,10 +1956,44 @@ switch_to_eh_frame_section (void) { tree label; +#ifdef EH_FRAME_SECTION_NAME + if (eh_frame_section == 0) + { + int flags; + + if (EH_TABLES_CAN_BE_READ_ONLY) + { + int fde_encoding; + int per_encoding; + int lsda_encoding; + + fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, + /*global=*/0); + per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, + /*global=*/1); + lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, + /*global=*/0); + flags = ((! flag_pic + || ((fde_encoding & 0x70) != DW_EH_PE_absptr + && (fde_encoding & 0x70) != DW_EH_PE_aligned + && (per_encoding & 0x70) != DW_EH_PE_absptr + && (per_encoding & 0x70) != DW_EH_PE_aligned + && (lsda_encoding & 0x70) != DW_EH_PE_absptr + && (lsda_encoding & 0x70) != DW_EH_PE_aligned)) + ? 0 : SECTION_WRITE); + } + else + flags = SECTION_WRITE; + eh_frame_section = get_section (EH_FRAME_SECTION_NAME, flags, NULL); + } +#endif + if (eh_frame_section) switch_to_section (eh_frame_section); else { + /* We have no special eh_frame section. Put the information in + the data section and emit special labels to guide collect2. */ switch_to_section (data_section); label = get_file_function_name ('F'); ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); diff --git a/gcc/except.c b/gcc/except.c index 782a516abfb..f8aed34c511 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -3425,30 +3425,34 @@ sjlj_output_call_site_table (void) call_site_base += n; } -/* Return the default value of exception_section. */ +/* Switch to the section that should be used for exception tables. */ -section * -default_exception_section (void) +static void +switch_to_exception_section (void) { - if (targetm.have_named_sections) + if (exception_section == 0) { - int flags; - - if (EH_TABLES_CAN_BE_READ_ONLY) + if (targetm.have_named_sections) { - int tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1); - - flags = (! flag_pic - || ((tt_format & 0x70) != DW_EH_PE_absptr - && (tt_format & 0x70) != DW_EH_PE_aligned)) - ? 0 : SECTION_WRITE; + int flags; + + if (EH_TABLES_CAN_BE_READ_ONLY) + { + int tt_format = + ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1); + flags = ((! flag_pic + || ((tt_format & 0x70) != DW_EH_PE_absptr + && (tt_format & 0x70) != DW_EH_PE_aligned)) + ? 0 : SECTION_WRITE); + } + else + flags = SECTION_WRITE; + exception_section = get_section (".gcc_except_table", flags, NULL); } else - flags = SECTION_WRITE; - return get_section (".gcc_except_table", flags, NULL); + exception_section = flag_pic ? data_section : readonly_data_section; } - else - return flag_pic ? data_section : readonly_data_section; + switch_to_section (exception_section); } @@ -3530,7 +3534,7 @@ output_function_exception_table (void) /* Note that varasm still thinks we're in the function's code section. The ".endp" directive that will immediately follow will take us back. */ #else - switch_to_section (exception_section); + switch_to_exception_section (); #endif have_tt_data = (VEC_length (tree, cfun->eh->ttype_data) > 0 diff --git a/gcc/output.h b/gcc/output.h index 47989e94422..5ea0faaf8ae 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -384,12 +384,6 @@ extern const char *user_label_prefix; /* Default target function prologue and epilogue assembler output. */ extern void default_function_pro_epilogue (FILE *, HOST_WIDE_INT); -/* Return the default value of exception_section. */ -extern section *default_exception_section (void); - -/* Return the default value of eh_frame_section. */ -extern section *default_eh_frame_section (void); - /* Default target hook that outputs nothing to a stream. */ extern void no_asm_to_stream (FILE *); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e33451994a..63ef74e45e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-12-10 Richard Sandiford <richard@codesourcery.com> + + * gcc.dg/20051207-1.c, + * gcc.dg/20051207-2.c, + * gcc.dg/20051207-3.c: New tests. + 2005-12-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> PR testsuite/20772 diff --git a/gcc/testsuite/gcc.dg/20051207-1.c b/gcc/testsuite/gcc.dg/20051207-1.c new file mode 100644 index 00000000000..326fb0271a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20051207-1.c @@ -0,0 +1,5 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame, even if it thinks that .eh_frame should be read-only. */ +/* { dg-require-named-sections "" } */ +int a __attribute__((section (".eh_frame"))) = 1; diff --git a/gcc/testsuite/gcc.dg/20051207-2.c b/gcc/testsuite/gcc.dg/20051207-2.c new file mode 100644 index 00000000000..8a8708794a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20051207-2.c @@ -0,0 +1,5 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame, even if it thinks that .eh_frame should be read-write. */ +/* { dg-require-named-sections "" } */ +const int a __attribute__((section (".eh_frame"))) = 1; diff --git a/gcc/testsuite/gcc.dg/20051207-3.c b/gcc/testsuite/gcc.dg/20051207-3.c new file mode 100644 index 00000000000..3d4b2a48c39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20051207-3.c @@ -0,0 +1,7 @@ +/* GCC doesn't generate any .eh_frame data for this TU itself, so it + shouldn't warn about "a" conflicting with the built-in idea of + .eh_frame. The warning therefore belongs on the second decl. */ +/* { dg-options "-fno-unit-at-a-time" } */ +/* { dg-require-named-sections "" } */ +int a __attribute__((section (".eh_frame"))) = 1; +const int b __attribute__((section (".eh_frame"))) = 1; /* { dg-error "section type conflict" } */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 4285d15aa76..244d6d8dfc4 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -155,12 +155,14 @@ section *sbss_section; section *init_section; section *fini_section; -/* The section that holds the main exception table. */ +/* The section that holds the main exception table, when known. The section + is set either by the target's init_sections hook or by the first call to + switch_to_exception_section. */ section *exception_section; -/* The section that holds the DWARF2 frame unwind information. If it - is null, we will place the unwind information in the data section - and emit special labels to guide collect2. */ +/* The section that holds the DWARF2 frame unwind information, when known. + The section is set either by the target's init_sections hook or by the + first call to switch_to_eh_frame_section. */ section *eh_frame_section; /* asm_out_file's current section. This is NULL if no section has yet @@ -230,10 +232,11 @@ get_section (const char *name, unsigned int flags, tree decl) slot = (section **) htab_find_slot_with_hash (section_htab, name, htab_hash_string (name), INSERT); + flags |= SECTION_NAMED; if (*slot == NULL) { sect = ggc_alloc (sizeof (struct named_section)); - sect->named.common.flags = flags | SECTION_NAMED; + sect->named.common.flags = flags; sect->named.name = ggc_strdup (name); sect->named.decl = decl; *slot = sect; @@ -241,7 +244,7 @@ get_section (const char *name, unsigned int flags, tree decl) else { sect = *slot; - if ((sect->common.flags & ~(SECTION_DECLARED | SECTION_NAMED)) != flags + if ((sect->common.flags & ~SECTION_DECLARED) != flags && ((sect->common.flags | flags) & SECTION_OVERRIDE) == 0) { /* Sanity check user variables for flag changes. */ @@ -4868,10 +4871,6 @@ init_varasm_once (void) if (readonly_data_section == NULL) readonly_data_section = text_section; - if (exception_section == NULL) - exception_section = default_exception_section (); - if (eh_frame_section == NULL) - eh_frame_section = default_eh_frame_section (); } enum tls_model |