diff options
author | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-12 17:09:03 +0000 |
---|---|---|
committer | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-12 17:09:03 +0000 |
commit | 2f9fc8efd7791829d4e81d6945cbe12ded8f94c3 (patch) | |
tree | caa8a2f6e25f2a2ca455a215f64f01003c8ba7c4 /gcc/dwarf2out.c | |
parent | cd5edb432360227353f9d74a01082afedd347898 (diff) | |
download | gcc-2f9fc8efd7791829d4e81d6945cbe12ded8f94c3.tar.gz |
Enabled linkonce support for Darwin.
* target.h (struct gcc_target): New target hook, unwind_label.
* target-def.h (TARGET_ASM_EMIT_UNWIND_LABEL): New hook.
* output.h (default_emit_unwind_label): New function.
* default.h (TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY): New macro.
(TARGET_USES_WEAK_UNWIND_INFO): New target macro.
(TARGET_SUPPORTS_HIDDEN): New target macro.
* dwarf2out.c (struct dw_fde_struct): Add field for function decl
that corresponds to this FDE.
(FRAME_BEGIN_LABEL): Allow target to override default label.
(output_call_frame_info): If FDEs are linknonce, then use extra
indirection for FDE encoding, output a label for each FDE, and
output an empty label for each function without an FDE.
(dwarf2out_begin_prologue): Set up decl field when creating an FDE.
* varasm.c (globalize_decl): Call ASM_MAKE_LABEL_LINKONCE for
decls with DECL_ONE_ONLY set, if that macro is defined.
(make_decl_one_only): Don't use DECL_COMMON if we're compiling
for a SUPPORTS_ONE_ONLY target.
* config/darwin-protos.h (darwin_unique_section): Declare.
(darwin_asm_named_section): Likewise.
(darwin_section_type_flags): Likewise.
(darwin_non_lazy_pcrel): Likewise.
(darwin_emit_unwind_label): Likewise.
(darwin_make_decl_one_only): Likewise.
* config/darwin.c (machopic_finish): Get rid of tweak that
eliminate stubs for symbols that are defined.
(darwin_encode_section_info): Don't treat weak functions as defined.
(darwin_make_decl_one_only): Define.
(darwin_asm_named_section): Likewise.
(darwin_section_type_flags): Likewise.
(darwin_unique_section): Likewise.
(darwin_emit_unwind_label): Likewise.
(darwin_non_lazy_pcrel): Likewise.
(darwin_asm_output_dwarf_delta): Difference between two labels is
local only if both labels are local.
* config/darwin.h (MAKE_DECL_ONE_ONLY): Define.
(ASM_MAKE_LABEL_LINKONCE): Likewise.
(TARGET_SUPPORTS_HIDDEN): Likewise.
(TARGET_USES_WEAK_UNWIND_INFO): Likewise.
(TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY): Likewise.
(FRAME_BEGIN_LABEL): Likewise.
(ASM_DECLARE_OBJECT_NAME): Make references to weak symbols indirect.
(ASM_DECLARE_FUNCTION_NAME): Likewise.
(darwin_eh_frame_section): Give __eh_frame section the coalesced flag.
(TARGET_ASM_UNIQUE_SECTION): Define.
(EH_FRAME_SECTION_NAME): Define.
(EH_FRAME_SECTION_ATTR): Likewise.
(ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX): Likewise.
(TARGET_ASM_NAMED_SECTION): Likewise.
(TARGET_SECTION_TYPE_FLAGS): Likewise.
* doc/tm.texi: Document TARGET_USES_WEAK_UNWIND_INFO,
TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY, TARGET_SUPPORTS_HIDDEN,
TARGET_ASM_EMIT_UNWIND_LABEL.
* cp/decl2.c (maybe_make_one_only): Look at
TARGET_EXPLICIT_INSTANTIATION_ONE_ONLY when deciding whether
to make an explicit instantiation weak.
* cp/method.c (use_thunk): Make sure we call comdat_linkage
when appropriate.
* cp/pt.c (do_type_instantiation): On systems where weak symbols
don't go in a static archive's TOC, explicit instantiation of a
class must imply *explicit* instantiation of its memeber.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79394 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 55947932ddb..90a9caa7ebf 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -243,6 +243,7 @@ typedef struct cfa_loc GTY(()) typedef struct dw_fde_struct GTY(()) { + tree decl; const char *dw_fde_begin; const char *dw_fde_current_label; const char *dw_fde_end; @@ -391,7 +392,9 @@ static void def_cfa_1 (const char *, dw_cfa_location *); #define FUNC_END_LABEL "LFE" #endif +#ifndef FRAME_BEGIN_LABEL #define FRAME_BEGIN_LABEL "Lframe" +#endif #define CIE_AFTER_SIZE_LABEL "LSCIE" #define CIE_END_LABEL "LECIE" #define FDE_LABEL "LSFDE" @@ -1942,6 +1945,22 @@ output_call_frame_info (int for_eh) if (fde_table_in_use == 0) return; + /* If we make FDEs linkonce, we may have to emit an empty label for + an FDE that wouldn't otherwise be emitted. We want to avoid + having an FDE kept around when the function it refers to is + discarded. (Example where this matters: a primary function + template in C++ requires EH information, but an explicit + specialization doesn't. */ + if (TARGET_USES_WEAK_UNWIND_INFO + && ! flag_asynchronous_unwind_tables + && for_eh) + for (i = 0; i < fde_table_in_use; i++) + if ((fde_table[i].nothrow || fde_table[i].all_throwers_are_sibcalls) + && !fde_table[i].uses_eh_lsda + && ! DECL_ONE_ONLY (fde_table[i].decl)) + (*targetm.asm_out.unwind_label) (asm_out_file, fde_table[i].decl, + /* empty */ 1); + /* If we don't have any functions we'll want to unwind out of, don't emit any EH unwind information. Note that if exceptions aren't enabled, we won't have collected nothrow information, and if we @@ -1953,6 +1972,9 @@ output_call_frame_info (int for_eh) for (i = 0; i < fde_table_in_use; i++) if (fde_table[i].uses_eh_lsda) any_eh_needed = any_lsda_needed = true; + else if (TARGET_USES_WEAK_UNWIND_INFO + && DECL_ONE_ONLY (fde_table[i].decl)) + any_eh_needed = 1; else if (! fde_table[i].nothrow && ! fde_table[i].all_throwers_are_sibcalls) any_eh_needed = true; @@ -2004,7 +2026,9 @@ output_call_frame_info (int for_eh) P Indicates the presence of an encoding + language personality routine in the CIE augmentation. */ - fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0); + fde_encoding = TARGET_USES_WEAK_UNWIND_INFO + ? ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1) + : 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); @@ -2095,9 +2119,11 @@ output_call_frame_info (int for_eh) /* Don't emit EH unwind info for leaf functions that don't need it. */ if (for_eh && !flag_asynchronous_unwind_tables && flag_exceptions && (fde->nothrow || fde->all_throwers_are_sibcalls) + && (! TARGET_USES_WEAK_UNWIND_INFO || ! DECL_ONE_ONLY (fde->decl)) && !fde->uses_eh_lsda) continue; + (*targetm.asm_out.unwind_label) (asm_out_file, fde->decl, /* empty */ 0); (*targetm.asm_out.internal_label) (asm_out_file, FDE_LABEL, for_eh + i * 2); ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2); ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i * 2); @@ -2113,9 +2139,16 @@ output_call_frame_info (int for_eh) if (for_eh) { - dw2_asm_output_encoded_addr_rtx (fde_encoding, - gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin), - "FDE initial location"); + if (TARGET_USES_WEAK_UNWIND_INFO + && DECL_ONE_ONLY (fde->decl)) + dw2_asm_output_encoded_addr_rtx (fde_encoding, + gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER + (DECL_ASSEMBLER_NAME (fde->decl))), + "FDE initial location"); + else + dw2_asm_output_encoded_addr_rtx (fde_encoding, + gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin), + "FDE initial location"); dw2_asm_output_delta (size_of_encoded_value (fde_encoding), fde->dw_fde_end, fde->dw_fde_begin, "FDE address range"); @@ -2248,6 +2281,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, /* Add the new FDE at the end of the fde_table. */ fde = &fde_table[fde_table_in_use++]; + fde->decl = current_function_decl; fde->dw_fde_begin = xstrdup (label); fde->dw_fde_current_label = NULL; fde->dw_fde_end = NULL; |