+2001-08-03 Richard Henderson <rth@redhat.com>
+
+ * target.h (gcc_target): Add asm_out.named_section,
+ section_type_flags, have_named_sections.
+ * target-def.h (TARGET_ASM_NAMED_SECTION): New.
+ (TARGET_HAVE_NAMED_SECTIONS): New.
+ (TARGET_SECTION_TYPE_FLAGS): New.
+
+ * Makefile.in (toplev.o): Depend on TARGET_H.
+ (varasm.o, dbxout.o): Likewise.
+ * c-common.c (decl_attributes): Check targetm.have_named_sections
+ instead of ifdef ASM_OUTPUT_SECTION_NAME.
+ * dbxout.c (dbxout_function_decl): Likewise.
+ (dbxout_function_end): Likewise.
+ * toplev.c (compile_file): Likewise.
+ * varasm.c (exception_section): Likewise.
+ * cp/decl2.c (finish_objects): Likewise.
+
+ * defaults.h (EH_FRAME_SECTION): Remove.
+ (EH_FRAME_SECTION_ASM_OP): Remove.
+ (EH_FRAME_SECTION_NAME): New.
+ (UNIQUE_SECTION): Don't depend on ASM_OUTPUT_SECTION_NAME.
+ (UNIQUE_SECTION_P): Remove.
+ * dwarf2out.c (SECTION_FORMAT): Remove.
+ (ASM_OUTPUT_SECTION): Remove.
+ (output_call_frame_info): Use named_section_flags.
+ (output_comp_unit, dwarf2out_start_source_file): Likewise.
+ (dwarf2out_end_source_file, dwarf2out_define): Likewise.
+ (dwarf2out_undef, dwarf2out_init, dwarf2out_finish): Likewise.
+ * varasm.c (in_eh_frame, eh_frame_section): Remove.
+ (named_section_flags): New.
+ (named_section): Use it and targetm.section_type_flags.
+ (resolve_unique_section): New.
+ (assemble_start_function): Use it.
+ (asm_emit_uninitialised, assemble_variable): Likewise.
+ (default_section_type_flags): New.
+ (default_no_named_section, default_elf_asm_named_section): New.
+ (default_coff_asm_named_section, default_pe_asm_named_section): New.
+ * output.h: Update varasm.c decls.
+ (SECTION_*): New flags.
+
+ * crtstuff.c: Check EH_FRAME_SECTION_NAME not EH_FRAME_SECTION_ASM_OP.
+ (__EH_FRAME_BEGIN__, __FRAME_END__): Use attribute section.
+
+ * config/elfos.h (UNIQUE_SECTION_P): Remove.
+ * config/alpha/elf.h, config/arm/linux-elf.h: Likewise.
+ * config/arm/pe.h, config/arm/unknown-elf.h: Likewise.
+ * config/i386/cygwin.h, config/i386/djgpp.h: Likewise.
+ * config/i386/i386-interix.h, config/i386/win32.h: Likewise.
+ * config/ia64/sysv4.h, config/mcore/mcore-pe.h: Likewise.
+ * config/mips/elf.h, config/mips/elf64.h: Likewise.
+ * config/mips/iris6gld.h, config/mips/mips.h: Likewise.
+ * config/pa/pa64-hpux.h,
+
+ * config/elfos.h (ASM_OUTPUT_SECTION_NAME): Remove.
+ (TARGET_ASM_NAMED_SECTION): New.
+ * config/psos.h, config/a29k/a29k.h, config/alpha/elf.h: Likewise.
+ * config/alpha/vms.h, config/arm/coff.h: Likewise.
+ * config/arm/conix-elf.h, config/arm/elf.h: Likewise.
+ * config/arm/linux-elf.h, config/arm/pe.h: Likewise.
+ * config/arm/unknown-elf.h, config/avr/avr.h: Likewise.
+ * config/c4x/c4x.h, config/h8300/h8300.h: Likewise.
+ * config/i386/cygwin.h, config/i386/djgpp.h: Likewise.
+ * config/i386/i386-interix.h, config/i386/i386elf.h : Likewise.
+ * config/i386/sco5.h, config/i386/win32.h: Likewise.
+ * config/m68k/coff.h, config/mcore/mcore-pe.h: Likewise.
+ * config/mcore/mcore.h, config/mips/elf.h: Likewise.
+ * config/mips/elf64.h, config/mips/iris6.h: Likewise.
+ * config/mips/netbsd.h, config/mips/openbsd.h: Likewise.
+ * config/pa/pa64-hpux.h, config/rs6000/sysv4.h: Likewise.
+ * config/rs6000/xcoff.h, config/sh/sh.h: Likewise.
+ * config/sparc/sysv4.h: Likewise.
+
+ * config/nextstep.h: Error until named sections implemented.
+
+ * config/a29k/a29k.c (a29k_asm_named_section): New.
+ * config/alpha/alpha.c (SECTION_VMS_OVERLAY): New.
+ (vms_section_type_flags, vms_asm_named_section): New.
+ * config/arm/arm.c (arm_elf_asm_named_section): New.
+ * config/avr/avr.c (asm_output_section_name): Remove.
+ * config/avr/avr-protos.h: Update.
+ * config/c4x/c4x.c (c4x_asm_named_section): New.
+ * config/h8300/h8300.c (h8300_asm_named_section): New.
+ * config/i386/i386.c (sco_asm_named_section): New.
+ * config/i386/winnt.c (SECTION_PE_SHARED): New.
+ (i386_pe_section_type_flags): New.
+ (i386_pe_asm_named_section): New.
+ * config/i386/i386-protos.h: Update.
+ * config/m68k/m68k.c (m68k_coff_asm_named_section): New.
+ * config/mcore/mcore.c (mcore_asm_named_section): New.
+ * config/mips/mips.c (iris6_asm_named_section): New.
+ * config/mips/mips.h (ENCODE_SECTION_INFO): Use DECL_ONE_ONLY
+ instead of UNIQUE_SECTION_P.
+ * config/rs6000/rs6000.c (rs6000_elf_section_type_flags): New.
+ (xcoff_asm_named_section): New.
+ * config/sh/sh.c (sh_asm_named_section): New.
+ * config/sparc/sparc.c (sparc_elf_asm_named_section): New.
+
+ * config/i386/djgpp.h (EH_FRAME_SECTION_ASM_OP): Remove.
+ * config/i386/sco5.h (EH_FRAME_SECTION_ASM_OP*): Remove.
+ (EH_FRAME_SECTION_NAME): New.
+ (EXCEPTION_SECTION): New.
+ * config/ia64/ia64.h (EH_FRAME_SECTION_ASM_OP): Remove.
+ (DEBUG_*_SECTION): Remove.
+ * config/m68k/rtemself.h (EH_FRAME_SECTION_ASM_OP): Remove.
+ * config/mips/iris6.h (DEBUG_*_SECTION): Remove.
+ (EH_FRAME_SECTION_ASM_OP): Remove.
+
+ * doc/tm.texi (UNIQUE_SECTION_P): Remove.
+ (ASM_OUTPUT_SECTION_NAME): Remove.
+ (TARGET_ASM_NAMED_SECTION): New.
+ (TARGET_HAVE_NAMED_SECTIONS): New.
+ (TARGET_SECTION_TYPE_FLAGS): New.
+ (EH_FRAME_SECTION_ASM_OP): Remove.
+ (EH_FRAME_SECTION_NAME): New.
+
2001-08-03 Zack Weinberg <zackw@stanford.edu>
* builtins.c (fold_builtin_constant_p): Return integer_zero_node
debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \
- ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h
+ ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H)
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \
-DTARGET_NAME=\"$(target_alias)\" \
-c $(srcdir)/toplev.c
varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \
function.h $(EXPR_H) hard-reg-set.h $(REGS_H) $(OBSTACK_H) \
output.h c-pragma.h toplev.h xcoffout.h debug.h $(GGC_H) $(TM_P_H) \
- $(HASHTAB_H)
+ $(HASHTAB_H) $(TARGET_H)
function.o : function.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
function.h $(EXPR_H) $(REGS_H) hard-reg-set.h \
insn-config.h $(RECOG_H) output.h toplev.h except.h hash.h $(GGC_H) $(TM_P_H)
insn-config.h $(EXPR_H) $(RECOG_H) reload.h \
toplev.h $(GGC_H) real.h $(TM_P_H) except.h
dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \
- $(REGS_H) debug.h $(TM_P_H) \
+ $(REGS_H) debug.h $(TM_P_H) $(TARGET_H) \
insn-config.h reload.h gstab.h xcoffout.h output.h dbxout.h toplev.h
debug.o : debug.c $(CONFIG_H) $(SYSTEM_H)
sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \
break;
case A_SECTION:
-#ifdef ASM_OUTPUT_SECTION_NAME
- if ((TREE_CODE (decl) == FUNCTION_DECL
- || TREE_CODE (decl) == VAR_DECL)
- && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
+ if (targetm.have_named_sections)
{
- if (TREE_CODE (decl) == VAR_DECL
- && current_function_decl != NULL_TREE
- && ! TREE_STATIC (decl))
- error_with_decl (decl,
- "section attribute cannot be specified for local variables");
- /* The decl may have already been given a section attribute from
- a previous declaration. Ensure they match. */
- else if (DECL_SECTION_NAME (decl) != NULL_TREE
- && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
- TREE_STRING_POINTER (TREE_VALUE (args))) != 0)
- error_with_decl (*node,
- "section of `%s' conflicts with previous declaration");
+ if ((TREE_CODE (decl) == FUNCTION_DECL
+ || TREE_CODE (decl) == VAR_DECL)
+ && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
+ {
+ if (TREE_CODE (decl) == VAR_DECL
+ && current_function_decl != NULL_TREE
+ && ! TREE_STATIC (decl))
+ error_with_decl (decl,
+ "section attribute cannot be specified for local variables");
+ /* The decl may have already been given a section attribute
+ from a previous declaration. Ensure they match. */
+ else if (DECL_SECTION_NAME (decl) != NULL_TREE
+ && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)),
+ TREE_STRING_POINTER (TREE_VALUE (args))) != 0)
+ error_with_decl (*node,
+ "section of `%s' conflicts with previous declaration");
+ else
+ DECL_SECTION_NAME (decl) = TREE_VALUE (args);
+ }
else
- DECL_SECTION_NAME (decl) = TREE_VALUE (args);
+ error_with_decl (*node,
+ "section attribute not allowed for `%s'");
}
else
error_with_decl (*node,
- "section attribute not allowed for `%s'");
-#else
- error_with_decl (*node,
- "section attributes are not supported for this target");
-#endif
+ "section attributes are not supported for this target");
break;
case A_ALIGNED:
static void check_epilogue_internal_label PARAMS ((FILE *));
static void output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void a29k_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
#define min(A,B) ((A) < (B) ? (A) : (B))
free (a29k_first_epilogue_insn);
a29k_first_epilogue_insn = 0;
}
+
+static void
+a29k_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ /* ??? Is it really correct to mark all sections as "bss"? */
+ fprintf (asm_out_file, "\t.sect %s, bss\n\t.use %s\n", name, name);
+}
extern int a29k_debug_reg_map[];
#define DBX_REGISTER_NUMBER(REGNO) a29k_debug_reg_map[REGNO]
-/* This how to write an assembler directive to FILE to switch to
- section NAME for DECL. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf (FILE, "\t.sect %s, bss\n\t.use %s\n", NAME, NAME)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION a29k_asm_named_section
/* 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. */
\f
/* Initialize the GCC target structure. */
#if TARGET_ABI_OPEN_VMS
- static int vms_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree));
-# undef TARGET_VALID_DECL_ATTRIBUTE
-# define TARGET_VALID_DECL_ATTRIBUTE vms_valid_decl_attribute_p
+static int vms_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree));
+static unsigned int vms_section_type_flags PARAMS ((tree, const char *, int));
+static void vms_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+# undef TARGET_VALID_DECL_ATTRIBUTE
+# define TARGET_VALID_DECL_ATTRIBUTE vms_valid_decl_attribute_p
+# undef TARGET_SECTION_TYPE_FLAGS
+# define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags
#endif
#undef TARGET_ASM_FUNCTION_END_PROLOGUE
splay_tree_foreach (alpha_links, alpha_write_one_linkage, stream);
}
+/* Given a decl, a section name, and whether the decl initializer
+ has relocs, choose attributes for the section. */
+
+#define SECTION_VMS_OVERLAY SECTION_FORGET
+
+static unsigned int
+vms_section_type_flags (decl, name, reloc)
+ tree decl;
+ const char *name;
+ int reloc;
+{
+ unsigned int flags = default_section_type_flags (decl, name, reloc);
+
+ if (decl && DECL_MACHINE_ATTRIBUTES (decl)
+ && lookup_attribute ("overlaid", DECL_MACHINE_ATTRIBUTES (decl)))
+ flags |= SECTION_VMS_OVERLAY;
+
+ return flags;
+}
+
+/* Switch to an arbitrary section NAME with attributes as specified
+ by FLAGS. ALIGN specifies any known alignment requirements for
+ the section; 0 if the default should be used. */
+
+static void
+vms_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align;
+{
+ const char *flag_str = "";
+
+ if (flags & SECTION_VMS_OVERLAY)
+ flag_str = ",OVR";
+ else if (flags & SECTION_DEBUG)
+ flag_str = ",NOWRT";
+
+ fprintf (asm_out_file, ".section\t%s%s\n", name, flag_str);
+
+ /* ??? An indicated alignment of 1 byte is only used by dwarf,
+ and for that we turn off auto-alignment. */
+ if (align == 1)
+ ASM_OUTPUT_ALIGN (asm_out_file, 0);
+}
+
#else
rtx
} \
}
-
-/* Switch into a generic section.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl.
-
- If the section has already been defined, we must not emit the
- attributes here. The SVR4 assembler does not recognize section
- redefinitions. If DECL is NULL, no attributes are emitted. */
-
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- do \
- { \
- static htab_t htab; \
- \
- struct section_info \
- { \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- }; \
- \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- PTR* slot; \
- \
- /* The names we put in the hashtable will always be the unique \
- versions gived to us by the stringtable, so we can just use \
- their addresses as the keys. */ \
- if (!htab) \
- htab = htab_create (31, \
- htab_hash_pointer, \
- htab_eq_pointer, \
- NULL); \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "ax"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = "a"; \
- else \
- type = SECT_RW, mode = "aw"; \
- \
- /* See if we already have an entry for this section. */ \
- slot = htab_find_slot (htab, NAME, INSERT); \
- if (!*slot) \
- { \
- s = (struct section_info *) xmalloc (sizeof (* s)); \
- s->type = type; \
- *slot = s; \
- fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \
- NAME, mode); \
- } \
- else \
- { \
- s = (struct section_info *) *slot; \
- if (DECL && s->type != type) \
- error_with_decl (DECL, \
- "%s causes a section type conflict"); \
- \
- fprintf (FILE, "\t.section\t%s\n", NAME); \
- } \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* A C statement (sans semicolon) to output an element in the table of
global constructors. */
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
-
#undef UNIQUE_SECTION
#define UNIQUE_SECTION(DECL, RELOC) \
do \
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
fprintf (FILE, "\t.align %d\n", LOG);
-#define ASM_OUTPUT_SECTION(FILE,SECTION) \
- (strcmp (SECTION, ".text") == 0) \
- ? text_section () \
- : named_section (NULL_TREE, SECTION, 0), \
- ASM_OUTPUT_ALIGN (FILE, 0) \
-
-#define ASM_OUTPUT_SECTION_NAME(FILE,DECL,NAME,RELOC) \
- do \
- { \
- const char *flags; \
- int ovr = 0; \
- if (DECL && DECL_MACHINE_ATTRIBUTES (DECL) \
- && lookup_attribute \
- ("overlaid", DECL_MACHINE_ATTRIBUTES (DECL))) \
- flags = ",OVR", ovr = 1; \
- else if (strncmp (NAME,".debug", 6) == 0) \
- flags = ",NOWRT"; \
- else \
- flags = ""; \
- fputc ('\n', (FILE)); \
- fprintf (FILE, ".section\t%s%s\n", NAME, flags); \
- if (ovr) \
- (NAME) = ""; \
- } while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION vms_asm_named_section
#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
do { literals_section(); \
HOST_WIDE_INT));
static int arm_comp_type_attributes PARAMS ((tree, tree));
static void arm_set_default_type_attributes PARAMS ((tree));
+static void arm_elf_asm_named_section PARAMS ((const char *,
+ unsigned int,
+ unsigned int));
#undef Hint
#undef Mmode
#undef Ulong
}
}
#endif /* AOF_ASSEMBLER */
+
+/* Switch to an arbitrary section NAME with attributes as specified
+ by FLAGS. ALIGN specifies any known alignment requirements for
+ the section; 0 if the default should be used.
+
+ Differs from the default elf version only in the prefix character
+ used before the section type. */
+
+static void
+arm_elf_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ char flagchars[8], *f = flagchars;
+ const char *type;
+
+ if (!(flags & SECTION_DEBUG))
+ *f++ = 'a';
+ if (flags & SECTION_WRITE)
+ *f++ = 'w';
+ if (flags & SECTION_CODE)
+ *f++ = 'x';
+ if (flags & SECTION_SMALL)
+ *f++ = 's';
+ *f = '\0';
+
+ if (flags & SECTION_BSS)
+ type = "nobits";
+ else
+ type = "progbits";
+
+ fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s\n",
+ name, flagchars, type);
+}
} \
while (0)
-/* A C statement to output something to the assembler file to switch to
- section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
- else \
- fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
\f
/* Support the ctors/dtors and other sections. */
asm (DTORS_SECTION_ASM_OP); \
func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"a\"\n", (NAME)); \
- else \
- fprintf (STREAM, "\t.section %s,\"aw\"\n", (NAME)); \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* The ARM development system defines __main. */
#define NAME__MAIN "__gccmain"
#define SYMBOL__MAIN __gccmain
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
#define UNIQUE_SECTION(DECL,RELOC) \
do \
{ \
}
#endif
-/* A C statement to output something to the assembler file to switch to
- section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL
- or NULL_TREE. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"ax\",%%progbits\n", NAME); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"a\"\n", NAME); \
- else if (! strncmp (NAME, ".bss", 4)) \
- fprintf (STREAM, "\t.section %s,\"aw\",%%nobits\n", NAME); \
- else \
- fprintf (STREAM, "\t.section %s,\"aw\"\n", NAME); \
- } \
- while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION arm_elf_asm_named_section
\f
/* Support the ctors/dtors sections for g++. */
#ifndef INT_ASM_OP
} \
}
-/* Switch into a generic section.
- This is currently only used to support section attributes.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \
- (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
- (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION arm_elf_asm_named_section
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
}
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
-
#define UNIQUE_SECTION(DECL, RELOC) \
do \
{ \
symbols must be explicitly imported from shared libraries (DLLs). */
#define MULTIPLE_SYMBOL_SPACES
-#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
-
#define UNIQUE_SECTION(DECL, RELOC) arm_pe_unique_section (DECL, RELOC)
#define SUPPORTS_ONE_ONLY 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
- else \
- fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
- /* Functions may have been compiled at various levels of \
- optimization so we can't use `same_size' here. \
- Instead, have the linker pick one. */ \
- if ((DECL) && DECL_ONE_ONLY (DECL)) \
- fprintf (STREAM, "\t.linkonce %s\n", \
- TREE_CODE (DECL) == FUNCTION_DECL \
- ? "discard" : "same_size"); \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section
\f
/* This outputs a lot of .req's to define alias for various registers.
Let's try to avoid this. */
asm (DTORS_SECTION_ASM_OP); \
func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"a\"\n", (NAME)); \
- else if (! strncmp (NAME, ".bss", 4)) \
- fprintf (STREAM, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (STREAM, "\t.section %s,\"aw\"\n", (NAME)); \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* The ARM development system defines __main. */
#define NAME__MAIN "__gccmain"
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
-
#define UNIQUE_SECTION(DECL, RELOC) \
do \
{ \
char *name));
extern void unique_section PARAMS ((tree decl, int reloc));
extern void encode_section_info PARAMS ((tree decl));
-extern void asm_output_section_name PARAMS ((FILE *file, tree decl,
- const char *name,
- int reloc));
extern int avr_progmem_p PARAMS ((tree decl));
}
-/* Output section name to file FILE
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl. */
-
-void
-asm_output_section_name(file, decl, name, reloc)
- FILE *file;
- tree decl;
- const char *name;
- int reloc ATTRIBUTE_UNUSED;
-{
- fprintf (file, ".section %s, \"%s\", @progbits\n", name,
- decl && TREE_CODE (decl) == FUNCTION_DECL ? "ax" :
- decl && TREE_READONLY (decl) ? "a" : "aw");
-}
-
-
/* The routine used to output NUL terminated strings. We use a special
version of this for most svr4 targets because doing so makes the
generated assembly code more compact (and thus faster to assemble)
Decode SYM_NAME and store the real name part in VAR, sans the
characters that encode section info. Define this macro if
`ENCODE_SECTION_INFO' alters the symbol's name string. */
-/* `UNIQUE_SECTION_P (DECL)'
- A C expression which evaluates to true if DECL should be placed
- into a unique section for some target-specific reason. If you do
- not define this macro, the default is `0'. Note that the flag
- `-ffunction-sections' will also cause functions to be placed into
- unique sections. */
#define UNIQUE_SECTION(DECL, RELOC) unique_section (DECL, RELOC)
/* `UNIQUE_SECTION (DECL, RELOC)'
link-time relocations. If you do not define this macro, GNU CC
will use the symbol name prefixed by `.' as the section name. */
-
#define ASM_FILE_START(STREAM) asm_file_start (STREAM)
/* A C expression which outputs to the stdio stream STREAM some
appropriate text to go at the start of an assembler file.
This macro need not be defined if the standard form of debugging
information for the debugger in use is appropriate. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- asm_output_section_name(FILE, DECL, NAME, RELOC)
-
-/* `ASM_OUTPUT_SECTION_NAME (STREAM, DECL, NAME, RELOC)'
- A C statement to output something to the assembler file to switch
- to section NAME for object DECL which is either a `FUNCTION_DECL',
- a `VAR_DECL' or `NULL_TREE'. RELOC indicates whether the initial
- value of EXP requires link-time relocations. Some target formats
- do not support arbitrary sections. Do not define this macro in
- such cases.
-
- At present this macro is only used to support section attributes.
- When this macro is undefined, section attributes are disabled. */
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
#define OBJC_PROLOGUE {}
/* A C statement to output any assembler statements which are
static int c4x_label_ref_used_p PARAMS ((rtx, rtx));
static int c4x_valid_type_attribute_p PARAMS ((tree, tree, tree, tree));
static void c4x_insert_attributes PARAMS ((tree, tree *));
+static void c4x_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
\f
/* Initialize the GCC target structure. */
#undef TARGET_VALID_TYPE_ATTRIBUTE
}
return NULL_RTX;
}
+
+static void
+c4x_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file, "\t.sect\t\"%s\"\n", name);
+}
} \
}
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf (FILE, "\t.sect\t\"%s\"\n", NAME);
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION c4x_asm_named_section
/* This is machine-dependent because it needs to push something
on the stack. */
the symbol's name string. */
/* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */
-/* A C expression which evaluates to true if DECL should be placed
- into a unique section for some target-specific reason. If you do
- not define this macro, the default is `0'. Note that the flag
- `-ffunction-sections' will also cause functions to be placed into
- unique sections.
-
- Defined in svr4.h. */
-/* #define UNIQUE_SECTION_P(DECL) */
-
-/* A C statement to build up a unique section name, expressed as a
STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'.
RELOC indicates whether the initial value of EXP requires
link-time relocations. If you do not define this macro, GNU CC
Defined in svr4.h. */
/* #define ASM_OUTPUT_IDENT(STREAM, STRING) */
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a `FUNCTION_DECL', a `VAR_DECL' or
- `NULL_TREE'. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases.
-
- At present this macro is only used to support section attributes. When this
- macro is undefined, section attributes are disabled.
-
- Defined in svr4.h. */
-/* #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) */
-
/* A C statement to output any assembler statements which are required to
precede any Objective C object definitions or message sending. The
statement is executed only when compiling an Objective C program. */
This macro need not be defined on most platforms. */
/* #define ASM_OUTPUT_EH_REGION_END() */
-/* A C expression to switch to the section in which the main exception table is
- to be placed (*note Sections::.). The default is a section named
- `.gcc_except_table' on machines that support named sections via
- `ASM_OUTPUT_SECTION_NAME', otherwise if `-fpic' or `-fPIC' is in effect, the
- `data_section', otherwise the `readonly_data_section'. */
-/* #define EXCEPTION_SECTION() */
-
-/* If defined, a C string constant for the assembler operation to switch to the
- section for exception handling frame unwind information. If not defined,
- GNU CC will provide a default definition if the target supports named
- sections. `crtstuff.c' uses this macro to switch to the appropriate
- section.
-
- You should define this symbol if your target supports DWARF 2 frame unwind
- information and the default definition does not work. */
-/* #define EH_FRAME_SECTION_ASM_OP */
-
/* A C expression that is nonzero if the normal exception table output should
be omitted.
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
-
#define UNIQUE_SECTION(DECL, RELOC) \
do \
{ \
} \
while (0)
-/* Switch into a generic section.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl.
-
- If the section has already been defined, we must not
- emit the attributes here. The SVR4 assembler does not
- recognize section redefinitions.
- If DECL is NULL, no attributes are emitted. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- do \
- { \
- static htab_t htab; \
- \
- struct section_info \
- { \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- }; \
- \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- PTR* slot; \
- \
- /* The names we put in the hashtable will always be the unique \
- versions gived to us by the stringtable, so we can just use \
- their addresses as the keys. */ \
- if (!htab) \
- htab = htab_create (31, \
- htab_hash_pointer, \
- htab_eq_pointer, \
- NULL); \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "ax"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = "a"; \
- else \
- type = SECT_RW, mode = "aw"; \
- \
- \
- /* See if we already have an entry for this section. */ \
- slot = htab_find_slot (htab, NAME, INSERT); \
- if (!*slot) \
- { \
- s = (struct section_info *) xmalloc (sizeof (* s)); \
- s->type = type; \
- *slot = s; \
- fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \
- NAME, mode); \
- } \
- else \
- { \
- s = (struct section_info *) *slot; \
- if (DECL && s->type != type) \
- error_with_decl (DECL, \
- "%s causes a section type conflict"); \
- \
- fprintf (FILE, "\t.section\t%s\n", NAME); \
- } \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* A C statement or statements to switch to the appropriate
section for output of RTX in mode MODE. RTX is some kind
static int h8300_valid_decl_attribute PARAMS ((tree, tree, tree, tree));
static void h8300_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void h8300_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void h8300_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
/* CPU_TYPE, says what cpu we're compiling for. */
int cpu_type;
return 0;
}
+
+static void
+h8300_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ /* ??? Perhaps we should be using default_coff_asm_named_section. */
+ fprintf (asm_out_file, "\t.section %s\n", name);
+}
fprintf (FILE, \
"\t.text\n.stabs \"\",%d,0,0,.Letext\n.Letext:\n", N_SO)
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf (FILE, "\t.section %s\n", NAME)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION h8300_asm_named_section
/* 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. */
symbols must be explicitly imported from shared libraries (DLLs). */
#define MULTIPLE_SYMBOL_SPACES
-#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
extern void i386_pe_unique_section PARAMS ((TREE, int));
#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
#define SUPPORTS_ONE_ONLY 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
-do { \
- static struct section_info \
- { \
- struct section_info *next; \
- char *name; \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- } *sections; \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- \
- for (s = sections; s; s = s->next) \
- if (!strcmp (NAME, s->name)) \
- break; \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "x"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = ""; \
- else \
- { \
- type = SECT_RW; \
- if (DECL && TREE_CODE (DECL) == VAR_DECL \
- && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (DECL))) \
- mode = "ws"; \
- else \
- mode = "w"; \
- } \
- \
- if (s == 0) \
- { \
- s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
- s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
- strcpy (s->name, NAME); \
- s->type = type; \
- s->next = sections; \
- sections = s; \
- fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
- /* Functions may have been compiled at various levels of \
- optimization so we can't use `same_size' here. Instead, \
- have the linker pick one. */ \
- if ((DECL) && DECL_ONE_ONLY (DECL)) \
- fprintf (STREAM, "\t.linkonce %s\n", \
- TREE_CODE (DECL) == FUNCTION_DECL \
- ? "discard" : "same_size"); \
- } \
- else \
- { \
- fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
- } \
-} while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section
+
+/* Select attributes for named sections. */
+#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags
/* Write the extra assembler code needed to declare a function
properly. If we are generating SDB debugging information, this
#undef DTORS_SECTION_ASM_OP
#define DTORS_SECTION_ASM_OP "\t.section .dtor"
-/* Define the name of the .eh_frame section. */
-#undef EH_FRAME_SECTION_ASM_OP
-#define EH_FRAME_SECTION_ASM_OP "\t.section .eh_frame"
-
/* Define the name of the .ident op. */
#undef IDENT_ASM_OP
#define IDENT_ASM_OP "\t.ident\t"
fprintf (FILE, "\n"); \
} while (0)
-/* Tell GCC how to output a section name. Add "x" for code sections. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\
- do { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf ((FILE), "\t.section %s,\"x\"\n", (NAME)); \
- else \
- fprintf ((FILE), "\t.section %s\n", (NAME)); \
- } while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
do { \
#undef MAKE_DECL_ONE_ONLY
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-/* Additional support for C++ templates and support for
- garbage collection. */
-#undef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
-
#undef UNIQUE_SECTION
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
} \
}
-#if 0
-/* Currently gas chokes on this; that's not too hard to fix, but there's
- not a lot of impeteus to do it, either. If it is done, gas will have
- to handle long section name escapes (which are defined in the COFF/PE
- document as /nnn where nnn is a string table index). The benefit:
- section attributes and -ffunction-sections, neither of which seem to
- be critical. */
-/* gas may have been fixed? bfd was. */
-
-/* Switch into a generic section.
- This is currently only used to support section attributes.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
- fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
- (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
- (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
-#endif
-
/* The MS compilers take alignment as a number of bytes, so we do as well */
#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
symbols must be explicitly imported from shared libraries (DLLs). */
#define MULTIPLE_SYMBOL_SPACES
-#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
extern void i386_pe_unique_section ();
#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
#define SUPPORTS_ONE_ONLY 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
-do { \
- static struct section_info \
- { \
- struct section_info *next; \
- char *name; \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- } *sections; \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- \
- for (s = sections; s; s = s->next) \
- if (!strcmp (NAME, s->name)) \
- break; \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "x"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = "r"; \
- else \
- type = SECT_RW, mode = "w"; \
- \
- if (s == 0) \
- { \
- s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
- s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
- strcpy (s->name, NAME); \
- s->type = type; \
- s->next = sections; \
- sections = s; \
- fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
- /* Functions may have been compiled at various levels of \
- optimization so we can't use `same_size' here. Instead, \
- have the linker pick one. */ \
- if ((DECL) && DECL_ONE_ONLY (DECL)) \
- fprintf (STREAM, "\t.linkonce %s\n", \
- TREE_CODE (DECL) == FUNCTION_DECL \
- ? "discard" : "same_size"); \
- } \
- else \
- { \
- fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \
- } \
-} while (0)
-
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section
#endif /* 0 */
/* DWARF2 Unwinding doesn't work with exception handling yet. */
extern int ix86_valid_type_attribute_p PARAMS ((tree, tree, tree, tree));
extern int i386_pe_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree));
extern int i386_pe_valid_type_attribute_p PARAMS ((tree, tree, tree, tree));
+extern unsigned int i386_pe_section_type_flags PARAMS ((tree, const char *,
+ int));
+extern void i386_pe_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
#endif
static int ix86_save_reg PARAMS ((int, int));
static void ix86_compute_frame_layout PARAMS ((struct ix86_frame *));
static int ix86_comp_type_attributes PARAMS ((tree, tree));
+
+#if defined(TARGET_ELF) && defined(TARGET_COFF)
+static void sco_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+#endif
\f
/* Initialize the GCC target structure. */
#undef TARGET_VALID_TYPE_ATTRIBUTE
/* ??? Binutils 2.10 and earlier has a linkonce elimination bug related
to updating relocations to a section being discarded such that this
doesn't work. Ought to detect this at configure time. */
-#if 0 && defined (ASM_OUTPUT_SECTION_NAME)
+#if 0
/* The trick here is to create a linkonce section containing the
pic label thunk, but to refer to it with an internal label.
Because the label is internal, we don't have inter-dso name
In order to use these macros, however, we must create a fake
function decl. */
- {
- tree decl = build_decl (FUNCTION_DECL,
- get_identifier ("i686.get_pc_thunk"),
- error_mark_node);
- DECL_ONE_ONLY (decl) = 1;
- UNIQUE_SECTION (decl, 0);
- named_section (decl, NULL, 0);
- }
+ if (targetm.have_named_sections)
+ {
+ tree decl = build_decl (FUNCTION_DECL,
+ get_identifier ("i686.get_pc_thunk"),
+ error_mark_node);
+ DECL_ONE_ONLY (decl) = 1;
+ UNIQUE_SECTION (decl, 0);
+ named_section (decl, NULL, 0);
+ }
+ else
#else
- text_section ();
+ text_section ();
#endif
/* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
fprintf (file, "\tret\n");
ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (label));
}
+
+#if defined(TARGET_ELF) && defined(TARGET_COFF)
+static void
+sco_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align;
+{
+ if (TARGET_ELF)
+ default_elf_asm_named_section (name, flags, align);
+ else
+ default_coff_asm_named_section (name, flags, align);
+}
+#endif
#define LOCAL_LABEL_PREFIX "."
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
-do { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (FILE, ".section\t%s,\"ax\"\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (FILE, ".section\t%s,\"a\"\n", (NAME)); \
- else \
- fprintf (FILE, ".section\t%s,\"aw\"\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* If defined, a C expression whose value is a string containing the
assembler operation to identify the following data as
#define GLOBAL_ASM_OP "\t.globl\t"
#undef EH_FRAME_SECTION_ASM_OP
-#define EH_FRAME_SECTION_ASM_OP_COFF "\t.section\t.ehfram, \"x\""
-#define EH_FRAME_SECTION_ASM_OP_ELF "\t.section\t.eh_frame, \"aw\""
-#define EH_FRAME_SECTION_ASM_OP \
- ((TARGET_ELF) ? EH_FRAME_SECTION_ASM_OP_ELF : EH_FRAME_SECTION_ASM_OP_COFF)
+#define EH_FRAME_SECTION_NAME_COFF ".ehfram"
+#define EH_FRAME_SECTION_NAME_ELF ".eh_frame"
+#define EH_FRAME_SECTION_NAME \
+ ((TARGET_ELF) ? EH_FRAME_SECTION_NAME_ELF : EH_FRAME_SECTION_NAME_COFF)
/* Avoid problems (long sectino names, forward assembler refs) with DWARF
exception unwinding when we're generating COFF */
#define USER_LABEL_PREFIX ""
/*
- * Compensate for the difference between ELF and COFF assembler syntax.
- * Otherwise, this is cribbed from ../svr4.h.
* We rename 'gcc_except_table' to the shorter name in preparation
- * for the day when we're ready to do DWARF2 eh unwinding under COFF
+ * for the day when we're ready to do DWARF2 eh unwinding under COFF.
*/
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
-do { \
- static struct section_info \
- { \
- struct section_info *next; \
- char *name; \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- } *sections; \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- const char *sname = NAME ; \
- if (strcmp(NAME, ".gcc_except_table") == 0) sname = ".gccexc" ; \
- \
- for (s = sections; s; s = s->next) \
- if (!strcmp (NAME, s->name)) \
- break; \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = (TARGET_ELF) ? "ax" : "x" ; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = "a"; \
- else \
- type = SECT_RW, mode = (TARGET_ELF) ? "aw" : "w" ; \
- \
- if (s == 0) \
- { \
- s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
- s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
- strcpy (s->name, NAME); \
- s->type = type; \
- s->next = sections; \
- sections = s; \
- fprintf (FILE, ".section\t%s,\"%s\"%s\n", sname, mode, \
- (TARGET_ELF) ? ",@progbits" : "" ); \
- } \
- else \
- { \
- if (DECL && s->type != type) \
- error_with_decl (DECL, "%s causes a section type conflict"); \
- \
- fprintf (FILE, ".section\t%s\n", sname); \
- } \
-} while (0)
+#define EXCEPTION_SECTION() named_section (NULL, ".gccexc", 1)
+
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION sco_asm_named_section
#undef ASM_OUTPUT_SKIP
#define ASM_OUTPUT_SKIP(FILE,SIZE) \
# undef FINI_SECTION_ASM_OP
# undef CTORS_SECTION_ASM_OP
# undef DTORS_SECTION_ASM_OP
-# undef EH_FRAME_SECTION_ASM_OP
+# undef EH_FRAME_SECTION_NAME
# undef CTOR_LIST_BEGIN
# undef CTOR_LIST_END
# undef DO_GLOBAL_CTORS_BODY
# define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_ELF
# define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_ELF
# define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_ELF
-# define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_ELF
+# define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_ELF
# else /* ! _SCO_ELF */
# define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_COFF
# define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_COFF
# define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_COFF
# define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_COFF
-# define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_COFF
+# define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_COFF
# define CTOR_LIST_BEGIN asm (INIT_SECTION_ASM_OP); asm ("pushl $0")
# define CTOR_LIST_END CTOR_LIST_BEGIN
# define DO_GLOBAL_CTORS_BODY \
symbols must be explicitly imported from shared libraries (DLLs). */
#define MULTIPLE_SYMBOL_SPACES
-#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
extern void i386_pe_unique_section ();
#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
#define SUPPORTS_ONE_ONLY 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
-do { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
- else \
- fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
- /* Functions may have been compiled at various levels of \
- optimization so we can't use `same_size' here. Instead, \
- have the linker pick one. */ \
- if ((DECL) && DECL_ONE_ONLY (DECL)) \
- fprintf (STREAM, "\t.linkonce %s\n", \
- TREE_CODE (DECL) == FUNCTION_DECL \
- ? "discard" : "same_size"); \
-} while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section
+
+/* Select attributes for named sections. */
+#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags
#undef ASM_COMMENT_START
#define ASM_COMMENT_START " #"
#include "flags.h"
#include "tm_p.h"
#include "toplev.h"
+#include "hashtab.h"
/* i386/PE specific attribute support.
int
i386_pe_valid_decl_attribute_p (decl, attributes, attr, args)
tree decl;
- tree attributes;
+ tree attributes ATTRIBUTE_UNUSED;
tree attr;
tree args;
{
DECL_SECTION_NAME (decl) = build_string (len, string);
}
+
+/* Select a set of attributes for section NAME based on the properties
+ of DECL and whether or not RELOC indicates that DECL's initializer
+ might contain runtime relocations.
+
+ We make the section read-only and executable for a function decl,
+ read-only for a const data decl, and writable for a non-const data decl.
+
+ If the section has already been defined, to not allow it to have
+ different attributes, as (1) this is ambiguous since we're not seeing
+ all the declarations up front and (2) some assemblers (e.g. SVR4)
+ do not recoginize section redefinitions. */
+/* ??? This differs from the "standard" PE implementation in that we
+ handle the SHARED variable attribute. Should this be done for all
+ PE targets? */
+
+#define SECTION_PE_SHARED SECTION_MACH_DEP
+
+unsigned int
+i386_pe_section_type_flags (decl, name, reloc)
+ tree decl;
+ const char *name;
+ int reloc;
+{
+ static htab_t htab;
+ unsigned int flags;
+ unsigned int **slot;
+
+ /* The names we put in the hashtable will always be the unique
+ versions gived to us by the stringtable, so we can just use
+ their addresses as the keys. */
+ if (!htab)
+ htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL);
+
+ if (decl && TREE_CODE (decl) == FUNCTION_DECL)
+ flags = SECTION_CODE;
+ else if (decl && DECL_READONLY_SECTION (decl, reloc))
+ flags = 0;
+ else
+ {
+ flags = SECTION_WRITE;
+
+ if (decl && TREE_CODE (decl) == VAR_DECL
+ && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (decl)))
+ flags |= SECTION_PE_SHARED;
+ }
+
+ if (decl && DECL_ONE_ONLY (decl))
+ flags |= SECTION_LINKONCE;
+
+ /* See if we already have an entry for this section. */
+ slot = (unsigned int **) htab_find_slot (htab, name, INSERT);
+ if (!*slot)
+ {
+ *slot = (unsigned int *) xmalloc (sizeof (unsigned int));
+ **slot = flags;
+ }
+ else
+ {
+ if (decl && **slot != flags)
+ error_with_decl (decl, "%s causes a section type conflict");
+ }
+
+ return flags;
+}
+
+void
+i386_pe_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ char flagchars[8], *f = flagchars;
+
+ if (flags & SECTION_CODE)
+ *f++ = 'x';
+ if (flags & SECTION_WRITE)
+ *f++ = 'w';
+ if (flags & SECTION_PE_SHARED)
+ *f++ = 's';
+ *f = '\0';
+
+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
+
+ if (flags & SECTION_LINKONCE)
+ {
+ /* Functions may have been compiled at various levels of
+ optimization so we can't use `same_size' here.
+ Instead, have the linker pick one. */
+ fprintf (asm_out_file, "\t.linkonce %s\n",
+ (flags & SECTION_CODE ? "discard" : "same_size"));
+ }
+}
\f
/* The Microsoft linker requires that every function be marked as
DT_FCN. When using gas on cygwin, we must emit appropriate .type
\f
/* Assembler Commands for Exception Regions. */
-/* If defined, a C string constant for the assembler operation to switch to the
- section for exception handling frame unwind information. If not defined,
- GNU CC will provide a default definition if the target supports named
- sections. `crtstuff.c' uses this macro to switch to the appropriate
- section.
-
- You should define this symbol if your target supports DWARF 2 frame unwind
- information and the default definition does not work. */
-#define EH_FRAME_SECTION_ASM_OP "\t.section\t.IA_64.unwind,\"aw\""
-
/* Select a format to encode pointers in exception handling data. CODE
is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
true if the symbol may be affected by dynamic relocations. */
#define DWARF2_DEBUGGING_INFO
-/* Section names for DWARF2 debug info. */
-
-#define DEBUG_INFO_SECTION ".debug_info, \"\", \"progbits\""
-#define DEBUG_ABBREV_SECTION ".debug_abbrev, \"\", \"progbits\""
-#define DEBUG_ARANGES_SECTION ".debug_aranges, \"\", \"progbits\""
-#define DEBUG_MACINFO_SECTION ".debug_macinfo, \"\", \"progbits\""
-#define DEBUG_LINE_SECTION ".debug_line, \"\", \"progbits\""
-#define DEBUG_LOC_SECTION ".debug_loc, \"\", \"progbits\""
-#define DEBUG_PUBNAMES_SECTION ".debug_pubnames, \"\", \"progbits\""
-#define DEBUG_STR_SECTION ".debug_str, \"\", \"progbits\""
-#define DEBUG_RANGES_SECTION ".debug_ranges, \"\", \"progbits\""
-
/* C string constants giving the pseudo-op to use for a sequence of
2, 4, and 8 byte unaligned constants. dwarf2out.c needs these. */
ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \
} while (0)
-/* ??? Intel assembler does not allow "." in section names, so turn off
- gnu.linkonce section support, but only when using the Intel assembler. */
-#undef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (TARGET_GNU_AS ? DECL_ONE_ONLY (DECL) : 0)
-
/* The # tells the Intel assembler that this is not a register name.
However, we can't emit the # in a label definition, so we set a variable
in ASM_OUTPUT_LABEL to control whether we want the postfix here or not.
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
-/* Support generic sections */
-
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf((FILE), ".section\t%s,\"%c\"\n", (NAME), \
- (DECL) && (TREE_CODE (DECL) == FUNCTION_DECL || \
- DECL_READONLY_SECTION (DECL, RELOC)) ? 'x' : 'd')
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION m68k_coff_asm_named_section
/* Support the ctors and dtors sections for g++. */
static const char *singlemove_string PARAMS ((rtx *));
static void m68k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void m68k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void m68k_coff_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
\f
/* Alignment to use for loops and jumps */
}
return "eor%.l %2,%0";
}
+
+/* Output assembly to switch to section NAME with attribute FLAGS. */
+
+static void
+m68k_coff_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ char flagchar;
+
+ if (flags & SECTION_WRITE)
+ flagchar = 'd';
+ else
+ flagchar = 'x';
+
+ fprintf (asm_out_file, "\t.section\t%s,\"%c\"\n", name, flagchar);
+}
#undef FINI_SECTION_ASM_OP
#define FINI_SECTION_ASM_OP "\t.section\t.fini"
-#undef EH_FRAME_SECTION_ASM_OP
-#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame"
-
/* Do I need this? */
#undef INVOKE__main
#undef CONST_SECTION_ASM_OP
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
-#undef ASM_OUTPUT_SECTION_NAME
+#undef TARGET_ASM_NAMED_SECTION
#undef INIT_SECTION_ASM_OP
#undef FINI_SECTION_ASM_OP
#undef TYPE_ASM_OP
#undef DO_GLOBAL_DTORS_BODY
#undef INIT_SECTION_ASM_OP
-#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
-
#define SUPPORTS_ONE_ONLY 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
- do \
- { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (STREAM, "\t.section %s,\"x\"\n", NAME); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (STREAM, "\t.section %s,\"\"\n", NAME); \
- else \
- fprintf (STREAM, "\t.section %s,\"w\"\n", NAME); \
- /* Functions may have been compiled at various levels of \
- optimization so we can't use `same_size' here. \
- Instead, have the linker pick one. */ \
- if ((DECL) && DECL_ONE_ONLY (DECL)) \
- fprintf (STREAM, "\t.linkonce %s\n", \
- TREE_CODE (DECL) == FUNCTION_DECL \
- ? "discard" : "same_size"); \
- } \
- while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section
static int mcore_dllimport_p PARAMS ((tree));
static int mcore_valid_decl_attribute PARAMS ((tree, tree,
tree, tree));
+static void mcore_asm_named_section PARAMS ((const char *,
+ unsigned int,
+ unsigned int));
\f
/* Initialize the GCC target structure. */
#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
{
return lookup_attribute ("naked", DECL_MACHINE_ATTRIBUTES (current_function_decl)) != NULL_TREE;
}
+
+static void
+mcore_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file, "\t.section %s\n", name);
+}
} \
}
-
-#define ASM_OUTPUT_SECTION(file, nam) \
- do { fprintf (file, "\t.section\t%s\n", nam); } while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION mcore_asm_named_section
/* This is how to output an insn to push a register on the stack.
It need not be very fast code. */
#undef MAX_OFILE_ALIGNMENT
#define MAX_OFILE_ALIGNMENT (32768*8)
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
-do { \
- extern FILE *asm_out_text_file; \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
- else if (! strcmp (NAME, ".bss")) \
- fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* The following macro defines the format used to output the second
operand of the .type assembler directive. Different svr4 assemblers
} while (0)
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#undef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
#undef UNIQUE_SECTION
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
} while (0)
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
-do { \
- extern FILE *asm_out_text_file; \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
- else if (! strcmp (NAME, ".bss")) \
- fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* The following macro defines the format used to output the second
operand of the .type assembler directive. Different svr4 assemblers
} while (0)
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#undef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
#undef UNIQUE_SECTION
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
#define POPSECTION_ASM_OP "\t.popsection"
-#define DEBUG_INFO_SECTION ".debug_info,0x7000001e,0,0,1"
-#define DEBUG_LINE_SECTION ".debug_line,0x7000001e,0,0,1"
-#define DEBUG_SFNAMES_SECTION ".debug_sfnames,0x7000001e,0,0,1"
-#define DEBUG_SRCINFO_SECTION ".debug_srcinfo,0x7000001e,0,0,1"
-#define DEBUG_MACINFO_SECTION ".debug_macinfo,0x7000001e,0,0,1"
-#define DEBUG_PUBNAMES_SECTION ".debug_pubnames,0x7000001e,0,0,1"
-#define DEBUG_ARANGES_SECTION ".debug_aranges,0x7000001e,0,0,1"
-#define DEBUG_FRAME_SECTION ".debug_frame,0x7000001e,0x08000000,0,1"
-#define DEBUG_ABBREV_SECTION ".debug_abbrev,0x7000001e,0,0,1"
-#define DEBUG_LOC_SECTION ".debug_loc,0x7000001e,0,0,1"
-#define DEBUG_STR_SECTION ".debug_str,0x7000001e,0,0,1"
-#define DEBUG_RANGES_SECTION ".debug_ranges,0x7000001e,0,0,1"
-
/* ??? If no mabi=X option give, but a mipsX option is, then should depend
on the mipsX option. */
/* If no mips[3,4] option given, give the appropriate default for mabi=X */
#if _MIPS_SZPTR == 64
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,8"
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,8"
-#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,1,2,0,8"
#else /* _MIPS_SZPTR != 64 */
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,4"
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,4"
-#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,1,2,0,4"
-
#endif /* _MIPS_SZPTR == 64 */
#else /* ! (defined (CRT_BEGIN) || defined (CRT_END)) */
(Pmode == DImode ? "\t.section\t.ctors,1,2,0,8" : "\t.section\t.ctors,1,2,0,4")
#define DTORS_SECTION_ASM_OP \
(Pmode == DImode ? "\t.section\t.dtors,1,2,0,8" : "\t.section\t.dtors,1,2,0,4")
-#define EH_FRAME_SECTION_ASM_OP \
- (Pmode == DImode ? "\t.section\t.eh_frame,1,2,0,8" : "\t.section\t.eh_frame,1,2,0,4")
#endif /* defined (CRT_BEGIN) || defined (CRT_END) */
/* A default list of other sections which we might be "in" at any given
fprintf (FILE, "\n"); \
} while (0)
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. */
-
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
-do { \
- extern FILE *asm_out_text_file; \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (F, "\t.section %s,1,2,0,8\n", (NAME)); \
- else if (! strcmp (NAME, ".bss")) \
- fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION iris6_asm_named_section
/* Stuff for constructors. End here. */
/* The GNU linker supports one-only sections. */
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#undef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
#define UNIQUE_SECTION(DECL, RELOC) \
do \
{ \
static void mips_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void mips_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static enum processor_type mips_parse_cpu PARAMS ((const char *));
-
+static void iris6_asm_named_section PARAMS ((const char *,
+ unsigned int,
+ unsigned int));
/* Global variables for machine-dependent things. */
/* Threshold for data being put into the small data/bss area, instead
return cpu;
}
+
+/* Output assembly to switch to section NAME with attribute FLAGS. */
+
+static void
+iris6_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align;
+{
+ unsigned int sh_type, sh_flags, sh_entsize;
+
+ sh_flags = 0;
+ if (!(flags & SECTION_DEBUG))
+ sh_flags |= 2; /* SHF_ALLOC */
+ if (flags & SECTION_WRITE)
+ sh_flags |= 1; /* SHF_WRITE */
+ if (flags & SECTION_CODE)
+ sh_flags |= 4; /* SHF_EXECINSTR */
+ if (flags & SECTION_SMALL)
+ sh_flags |= 0x10000000; /* SHF_MIPS_GPREL */
+ if (strcmp (name, ".debug_frame") == 0)
+ sh_flags |= 0x08000000; /* SHF_MIPS_NOSTRIP */
+
+ if (flags & SECTION_DEBUG)
+ sh_type = 0x7000001e; /* SHT_MIPS_DWARF */
+ else if (flags & SECTION_BSS)
+ sh_type = 8; /* SHT_NOBITS */
+ else
+ sh_type = 1; /* SHT_PROGBITS */
+
+ if (flags & SECTION_CODE)
+ sh_entsize = 4;
+ else
+ sh_entsize = 0;
+
+ if (align == 0)
+ {
+ if (flags & SECTION_CODE)
+ align = 4;
+ else
+ align = 8;
+ }
+
+ fprintf (asm_out_file, "\t.section %s,%u,%u,%u,%u\n",
+ name, sh_type, sh_flags, sh_entsize, align);
+}
If you are changing this macro, you should look at
mips_select_section and see if it needs a similar change. */
-#ifndef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) (0)
-#endif
-
#define ENCODE_SECTION_INFO(DECL) \
do \
{ \
references again. We force it to work by putting string \
addresses in the constant pool and indirecting. */ \
&& (! current_function_decl \
- || ! UNIQUE_SECTION_P (current_function_decl))) \
+ || ! DECL_ONE_ONLY (current_function_decl))) \
{ \
SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 1; \
mips_string_length += TREE_STRING_LENGTH (DECL); \
} \
} while (0)
-/*
- A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases.
-*/
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
-do { \
- extern FILE *asm_out_text_file; \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
- else if (! strcmp (NAME, ".bss")) \
- fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* Since gas and gld are standard on NetBSD, we don't need these */
#undef ASM_FINAL_SPEC
#undef ASM_FINAL_SPEC
#undef STARTFILE_SPEC
-/* A C statement to output something to the assembler file to switch to
- section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL
- or NULL_TREE. Some target formats do not support arbitrary sections.
- Do not define this macro in such cases. mips.h doesn't define this,
- do it here. */
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
-do { \
- extern FILE *asm_out_text_file; \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
- else if (! strcmp (NAME, ".bss")) \
- fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \
- else \
- fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
-} while (0)
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* collect2 support (Macros for initialization). */
fprintf (FILE, ".reference .destructors_used\n"); \
} while (0)
+/* ??? Should be changed to EH_FRAME_SECTION_NAME, but that requires
+ named section support. Based on this definition, it seems clear
+ that the object file format supports named sections, but it has
+ not been implemented in gcc. */
+#error "Implement named section support"
#define EH_FRAME_SECTION_ASM_OP "\t.section __TEXT,__eh_frame,regular"
/* Don't output a .file directive. That is only used by the assembler for
} \
}
-/* Switch into a generic section.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl.
-
- If the section has already been defined, we must not
- emit the attributes here. The SVR4 assembler does not
- recognize section redefinitions.
- If DECL is NULL, no attributes are emitted. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- do \
- { \
- static htab_t htab; \
- \
- struct section_info \
- { \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- }; \
- \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- PTR* slot; \
- \
- /* The names we put in the hashtable will always be the unique \
- versions gived to us by the stringtable, so we can just use \
- their addresses as the keys. */ \
- if (!htab) \
- htab = htab_create (31, \
- htab_hash_pointer, \
- htab_eq_pointer, \
- NULL); \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "ax"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
- type = SECT_RO, mode = "a"; \
- else \
- type = SECT_RW, mode = "aw"; \
- \
- \
- /* See if we already have an entry for this section. */ \
- slot = htab_find_slot (htab, NAME, INSERT); \
- if (!*slot) \
- { \
- s = (struct section_info *) xmalloc (sizeof (* s)); \
- s->type = type; \
- *slot = s; \
- fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \
- NAME, mode); \
- } \
- else \
- { \
- s = (struct section_info *) *slot; \
- if (DECL && s->type != type) \
- error_with_decl (DECL, \
- "%s causes a section type conflict"); \
- \
- fprintf (FILE, "\t.section\t%s\n", NAME); \
- } \
- } \
- while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
-#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
int len; \
do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
fputc ('\n', FILE); } while (0)
-/* Switch into a generic section. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
- (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
- (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
-
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
/* Define the pseudo-ops used to switch to the .ctors and .dtors
sections. */
static void rs6000_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static rtx rs6000_emit_set_long_const PARAMS ((rtx,
HOST_WIDE_INT, HOST_WIDE_INT));
+#if TARGET_ELF
+static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *,
+ int));
+#endif
+#ifdef OBJECT_FORMAT_COFF
+static void xcoff_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+#endif
\f
/* Default register names. */
char rs6000_reg_names[][8] =
#undef TARGET_ASM_FUNCTION_EPILOGUE
#define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue
+#if TARGET_ELF
+#undef TARGET_SECTION_TYPE_FLAGS
+#define TARGET_SECTION_TYPE_FLAGS rs6000_elf_section_type_flags
+#endif
+
struct gcc_target targetm = TARGET_INITIALIZER;
\f
/* Override command line options. Mostly we process the processor
}
#endif /* TARGET_MACHO */
+
+#if TARGET_ELF
+static unsigned int
+rs6000_elf_section_type_flags (decl, name, reloc)
+ tree decl;
+ const char *name;
+ int reloc;
+{
+ unsigned int flags = default_section_type_flags (decl, name, reloc);
+
+ /* ??? The flag_pic check appears redundant with the DECL_READONLY_SECTION
+ check in default_section_type_flags. */
+ if (TARGET_RELOCATABLE || flag_pic)
+ flags &= ~SECTION_WRITE;
+
+ /* Solaris doesn't like @nobits, and gas can handle .sbss without it. */
+ flags &= ~SECTION_BSS;
+}
+#endif
+
+#ifdef OBJECT_FORMAT_COFF
+static void
+xcoff_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file, "\t.csect %s\n", name);
+}
+#endif
asm_fprintf (FILE, "%U%s", _name); \
} while (0)
-/* Switch into a generic section.
-
- We make the section read-only and executable for a function decl,
- read-only for a const data decl, and writable for a non-const data decl.
-
- If the section has already been defined, we must not
- emit the attributes here. The SVR4 assembler does not
- recognize section redefinitions.
- If DECL is NULL, no attributes are emitted.
-
- Note, Solaris as doesn't like @nobits, and gas can handle .sbss without
- needing @nobits. */
-
-/* Override elfos.h definition. */
-#undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
-do { \
- static struct section_info \
- { \
- struct section_info *next; \
- char *name; \
- enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
- } *sections; \
- struct section_info *s; \
- const char *mode; \
- enum sect_enum type; \
- \
- for (s = sections; s; s = s->next) \
- if (!strcmp (NAME, s->name)) \
- break; \
- \
- if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
- type = SECT_EXEC, mode = "ax"; \
- else if (DECL && DECL_READONLY_SECTION (DECL, RELOC) && !TARGET_RELOCATABLE && !flag_pic) \
- type = SECT_RO, mode = "a"; \
- else \
- type = SECT_RW, mode = "aw"; \
- \
- if (s == 0) \
- { \
- s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
- s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
- strcpy (s->name, NAME); \
- s->type = type; \
- s->next = sections; \
- sections = s; \
- fprintf (FILE, "\t.section\t\"%s\",\"%s\"\n", NAME, mode); \
- } \
- else \
- { \
- if (DECL && s->type != type) \
- error_with_decl (DECL, "%s causes a section type conflict"); \
- \
- fprintf (FILE, "\t.section\t\"%s\"\n", NAME); \
- } \
-} while (0)
-
/* Override elfos.h definition. */
#undef ASM_OUTPUT_CONSTRUCTOR
#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
} \
} while (0)
-#define ASM_OUTPUT_SECTION_NAME(ASM_OUT_FILE,DECL,NAME,RELOC) \
- do { fputs ("\t.csect ", ASM_OUT_FILE); \
- fputs (TREE_STRING_POINTER (DECL_SECTION_NAME (DECL)), ASM_OUT_FILE); \
- putc ('\n', ASM_OUT_FILE); \
- } while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION xcoff_asm_named_section
/* Define the name of the section to use for the exception tables.
TODO: test and see if we can use read_only_data_section, if so,
#undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
-#undef ASM_OUTPUT_SECTION_NAME
+#undef TARGET_ASM_NAMED_SECTION
#undef ASM_OUTPUT_CONSTRUCTOR
#undef ASM_OUTPUT_DESTRUCTOR
#undef ASM_DECLARE_FUNCTION_NAME
static int sh_valid_decl_attribute PARAMS ((tree, tree, tree, tree));
static void sh_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void sh_insert_attributes PARAMS ((tree, tree *));
+static void sh_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
\f
/* Initialize the GCC target structure. */
#undef TARGET_VALID_DECL_ATTRIBUTE
return 0;
}
+static void
+sh_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int flags ATTRIBUTE_UNUSED;
+{
+ /* ??? Perhaps we should be using default_coff_asm_named_section. */
+ fprintf (asm_out_file, "\t.section %s\n", name);
+}
which could be text or it could be a user defined section. */
#define JUMP_TABLES_IN_TEXT_SECTION 1
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
- do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION sh_asm_named_section
/* This is the pseudo-op used to generate a reference to a specific
symbol in some section. */
int));
static void sparc_nonflat_function_prologue PARAMS ((FILE *, HOST_WIDE_INT,
int));
+static void sparc_elf_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
\f
/* Option handling. */
ggc_add_root (ultra_pipe_hist, ARRAY_SIZE (ultra_pipe_hist),
sizeof (ultra_pipe_hist[0]), &mark_ultrasparc_pipeline_state);
}
+
+static void
+sparc_elf_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file, "\t.section\t\"%s\"", name);
+
+ if (!(flags & SECTION_DEBUG))
+ fputs (",#alloc", asm_out_file);
+ if (flags & SECTION_WRITE)
+ fputs (",#write", asm_out_file);
+ if (flags & SECTION_CODE)
+ fputs (",#execinstr", asm_out_file);
+
+ /* ??? Handle SECTION_BSS. */
+
+ fputc ('\n', asm_out_file);
+}
#define CTORS_SECTION_ASM_OP "\t.section\t\".ctors\",#alloc,#write"
#undef DTORS_SECTION_ASM_OP
#define DTORS_SECTION_ASM_OP "\t.section\t\".dtors\",#alloc,#write"
-#undef EH_FRAME_SECTION_ASM_OP
-#define EH_FRAME_SECTION_ASM_OP "\t.section\t\".eh_frame\",#alloc,#write"
-
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
-do { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (FILE, ".section\t\"%s\",#alloc,#execinstr\n", \
- (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \
- else \
- fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \
-} while (0)
+
+/* Switch into a generic section. */
+#undef TARGET_ASM_NAMED_SECTION
+#define TARGET_ASM_NAMED_SECTION sparc_elf_asm_named_section
/* A C statement (sans semicolon) to output to the stdio stream
FILE the assembler definition of uninitialized global DECL named
else
assemble_destructor (fnname);
}
-#if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR)
+#if defined (ASM_OUTPUT_CONSTRUCTOR)
/* If we're using init priority we can't use assemble_*tor, but on ELF
targets we can stick the references into named sections for GNU ld
to collect. */
- else
+ else if (targetm.have_named_sections)
{
char buf[15];
sprintf (buf, ".%ctors.%.5u", method_type == 'I' ? 'c' : 'd',
f ();
}
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
#if defined(CRT_GET_RFIB_TEXT) || defined(CRT_GET_RFIB_DATA)
/* If we used the new __register_frame_info_bases interface,
make sure that we deregister from the same place. */
asm (TEXT_SECTION_ASM_OP);
}
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
/* Stick a call to __register_frame_info into the .init section. For some
reason calls with no arguments work more reliably in .init, so stick the
call in another function. */
#endif
asm (TEXT_SECTION_ASM_OP);
}
-#endif /* EH_FRAME_SECTION_ASM_OP */
+#endif /* EH_FRAME_SECTION_NAME */
#else /* OBJECT_FORMAT_ELF */
for (p = __DTOR_LIST__ + 1; (f = *p); p++)
f ();
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
if (__deregister_frame_info)
__deregister_frame_info (__EH_FRAME_BEGIN__);
#endif
}
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
/* Define a function here to call __register_frame. crtend.o is linked in
after libgcc.a, and hence can't call libgcc.a functions directly. That
can lead to unresolved function references. */
STATIC func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
#endif
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
/* Stick a label at the beginning of the frame unwind info so we can register
and deregister it with the exception handling library code. */
-
-asm (EH_FRAME_SECTION_ASM_OP);
#ifdef INIT_SECTION_ASM_OP
STATIC
#endif
-char __EH_FRAME_BEGIN__[] = { };
-#endif /* EH_FRAME_SECTION_ASM_OP */
+char __EH_FRAME_BEGIN__[]
+ __attribute__((section(EH_FRAME_SECTION_NAME)))
+ = { };
+#endif /* EH_FRAME_SECTION_NAME */
#endif /* defined(CRT_BEGIN) */
not an SVR4-style .init section. __do_global_ctors can be non-static
in this case because we protect it with -hidden_symbol. */
static func_ptr __CTOR_END__[];
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
extern void __frame_dummy (void);
#endif
void
__do_global_ctors (void)
{
func_ptr *p;
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
__frame_dummy ();
#endif
for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
= { (func_ptr) 0 };
#endif
-#ifdef EH_FRAME_SECTION_ASM_OP
+#ifdef EH_FRAME_SECTION_NAME
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
this would be the 'length' field in a real FDE. */
-
-typedef unsigned int ui32 __attribute__ ((mode (SI)));
-asm (EH_FRAME_SECTION_ASM_OP);
-STATIC ui32 __FRAME_END__[] __attribute__ ((__unused__)) = { 0 };
+STATIC int __FRAME_END__[]
+ __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME)))
+ = { 0 };
#endif /* EH_FRAME_SECTION */
#endif /* defined(CRT_END) */
}
/* Terminate the frame section with a final zero. */
-
-/* Force cc1 to switch to .data section. */
-static void * force_to_data[1] __attribute__ ((__unused__)) = { };
-
-typedef unsigned int ui32 __attribute__ ((mode (SI)));
-asm (EH_FRAME_SECTION_ASM_OP);
-static ui32 __FRAME_END__[] __attribute__ ((__unused__)) = { 0 };
-
+STATIC int __FRAME_END__[]
+ __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME)))
+ = { 0 };
#endif /* CRT_END */
#endif /* OBJECT_FORMAT_MACHO */
#include "tm_p.h"
#include "ggc.h"
#include "debug.h"
+#include "target.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h"
static void dbxout_end_source_file PARAMS ((unsigned));
static void dbxout_source_line PARAMS ((unsigned int, const char *));
static void dbxout_source_file PARAMS ((FILE *, const char *));
-#if defined(ASM_OUTPUT_SECTION_NAME)
static void dbxout_function_end PARAMS ((void));
-#endif
static void dbxout_typedefs PARAMS ((tree));
static void dbxout_type_index PARAMS ((tree));
#if DBX_CONTIN_LENGTH > 0
};
#endif /* XCOFF_DEBUGGING_INFO */
\f
-#if defined(ASM_OUTPUT_SECTION_NAME)
static void
dbxout_function_end ()
{
assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
fprintf (asmfile, "\n");
}
-#endif /* ! NO_DBX_FUNCTION_END */
/* At the beginning of compilation, start writing the symbol table.
Initialize `typevec' and output the standard data types of C. */
#ifdef DBX_OUTPUT_FUNCTION_END
DBX_OUTPUT_FUNCTION_END (asmfile, decl);
#endif
-#if defined(ASM_OUTPUT_SECTION_NAME)
if (use_gnu_debug_info_extensions
#if defined(NO_DBX_FUNCTION_END)
&& ! NO_DBX_FUNCTION_END
#endif
- )
+ && targetm.have_named_sections)
dbxout_function_end ();
-#endif
}
#endif /* DBX_DEBUGGING_INFO */
#define DWARF2_UNWIND_INFO 1
#endif
-#if defined (DWARF2_UNWIND_INFO) && !defined (EH_FRAME_SECTION)
-# if defined (EH_FRAME_SECTION_ASM_OP)
-# define EH_FRAME_SECTION() eh_frame_section ()
-# else
- /* If we aren't using crtstuff to run ctors, don't use it for EH. */
-# if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR)
-# define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,\"aw\""
-# define EH_FRAME_SECTION() \
- do { named_section (NULL_TREE, ".eh_frame", 0); } while (0)
-# endif
-# endif
+/* If we have named section, and we're using crtstuff to run ctors,
+ then use named sections for registering eh frame information. */
+#if defined (TARGET_ASM_NAMED_SECTION) && defined (ASM_OUTPUT_CONSTRUCTOR)
+#ifndef EH_FRAME_SECTION_NAME
+#define EH_FRAME_SECTION_NAME ".eh_frame"
+#endif
#endif
/* If we have no definition for UNIQUE_SECTION, but do have the
ability to generate arbitrary sections, construct something
reasonable. */
-#ifdef ASM_OUTPUT_SECTION_NAME
#ifndef UNIQUE_SECTION
#define UNIQUE_SECTION(DECL,RELOC) \
do { \
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)
#endif
-#ifndef UNIQUE_SECTION_P
-#define UNIQUE_SECTION_P(DECL) 0
-#endif
-#endif
/* By default, we generate a label at the beginning and end of the
text section, and compute the size of the text section by
the characters that encode section info. Define this macro if
@code{ENCODE_SECTION_INFO} alters the symbol's name string.
-@findex UNIQUE_SECTION_P
-@item UNIQUE_SECTION_P (@var{decl})
-A C expression which evaluates to true if @var{decl} should be placed
-into a unique section for some target-specific reason. If you do not
-define this macro, the default is @samp{0}. Note that the flag
-@option{-ffunction-sections} will also cause functions to be placed into
-unique sections.
-
@findex UNIQUE_SECTION
@item UNIQUE_SECTION (@var{decl}, @var{reloc})
A C statement to build up a unique section name, expressed as a
@samp{#ident} directive containing the text @var{string}. If this
macro is not defined, nothing is output for a @samp{#ident} directive.
-@findex ASM_OUTPUT_SECTION_NAME
-@item ASM_OUTPUT_SECTION_NAME (@var{stream}, @var{decl}, @var{name}, @var{reloc})
-A C statement to output something to the assembler file to switch to section
-@var{name} for object @var{decl} which is either a @code{FUNCTION_DECL}, a
-@code{VAR_DECL} or @code{NULL_TREE}. @var{reloc}
-indicates whether the initial value of @var{exp} requires link-time
-relocations. The string given by @var{name} will always be the
-canonical version stored in the global stringpool.
-
-Some target formats do not support arbitrary sections. Do not define
-this macro in such cases.
-
-At present this macro is only used to support section attributes.
-When this macro is undefined, section attributes are disabled.
-
@findex OBJC_PROLOGUE
@item OBJC_PROLOGUE
A C statement to output any assembler statements which are required to
statement is executed only when compiling an Objective-C program.
@end table
+@deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, unsigned int @var{align})
+Output assembly directives to switch to section @var{name}. The section
+should have attributes as specified by @var{flags}, which is a bit mask
+of the @code{SECTION_*} flags defined in @file{output.h}. If @var{align}
+is non-zero, it contains an alignment in bytes to be used for the section,
+otherwise some target default should be used. Only targets that must
+specify an alignment within the section directive need pay attention to
+@var{align} -- we will still use @code{ASM_OUTPUT_ALIGN}.
+@end deftypefn
+
+@deftypefn {Target Hook} bool TARGET_HAVE_NAMED_SECTIONS
+This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
+@end deftypefn
+
+@deftypefn {Target Hook} {unsigned int} TARGET_SECTION_TYPE_FLAGS (tree @var{decl}, const char *@var{name}, int @var{reloc})
+Choose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION}
+based on a variable or function decl, a section name, and whether or not the
+declaration's initializer may contain runtime relocations. @var{decl} may be
+ null, in which case read-write data should be assumed.
+
+The default version if this function handles choosing code vs data,
+read-only vs read-write data, and @code{flag_pic}. You should only
+need to override this if your target has special flags that might be
+set via @code{__attribute__}.
+@end deftypefn
+
@need 2000
@node Data Output
@subsection Output of Data
A C expression to switch to the section in which the main
exception table is to be placed (@pxref{Sections}). The default is a
section named @code{.gcc_except_table} on machines that support named
-sections via @code{ASM_OUTPUT_SECTION_NAME}, otherwise if @option{-fpic}
+sections via @code{TARGET_ASM_NAMED_SECTION}, otherwise if @option{-fpic}
or @option{-fPIC} is in effect, the @code{data_section}, otherwise the
@code{readonly_data_section}.
-@findex EH_FRAME_SECTION_ASM_OP
-@item EH_FRAME_SECTION_ASM_OP
-If defined, a C string constant, including spacing, for the assembler
-operation to switch to the section for exception handling frame unwind
-information. If not defined, GCC will provide a default definition if the
-target supports named sections. @file{crtstuff.c} uses this macro to
-switch to the appropriate section.
+@findex EH_FRAME_SECTION_NAME
+@item EH_FRAME_SECTION_NAME
+If defined, a C string constant for the name of the section containing
+exception handling frame unwind information. If not defined, GCC will
+provide a default definition if the target supports named sections.
+@file{crtstuff.c} uses this macro to switch to the appropriate section.
You should define this symbol if your target supports DWARF 2 frame
unwind information and the default definition does not work.
#define SECTION_ASM_OP "\t.section\t"
#endif
-/* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
- print the SECTION_ASM_OP and the section name. The default here works for
- almost all svr4 assemblers, except for the sparc, where the section name
- must be enclosed in double quotes. (See sparcv4.h). */
-#ifndef SECTION_FORMAT
-#ifdef PUSHSECTION_FORMAT
-#define SECTION_FORMAT PUSHSECTION_FORMAT
-#else
-#define SECTION_FORMAT "%s%s\n"
-#endif
-#endif
-
#ifndef DEBUG_FRAME_SECTION
#define DEBUG_FRAME_SECTION ".debug_frame"
#endif
output operations. These may be overridden from within the tm.h file,
but typically, that is unnecessary. */
-#ifndef ASM_OUTPUT_SECTION
-#define ASM_OUTPUT_SECTION(FILE, SECTION) \
- fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
-#endif
-
#ifdef SET_ASM_OP
#ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
#define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
if (for_eh)
{
-#ifdef EH_FRAME_SECTION
- EH_FRAME_SECTION ();
+#ifdef EH_FRAME_SECTION_NAME
+ named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE,
+ DWARF_OFFSET_SIZE);
#else
tree label = get_file_function_name ('F');
- force_data_section ();
+ data_section ();
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
assemble_label ("__FRAME_BEGIN__");
}
else
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_FRAME_SECTION);
+ named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG, 1);
/* Output the CIE. */
ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
ASM_OUTPUT_LABEL (asm_out_file, l2);
}
-#ifndef EH_FRAME_SECTION
+#ifndef EH_FRAME_SECTION_NAME
if (for_eh)
dw2_asm_output_data (4, 0, "End of Table");
#endif
secname = (const char *) DEBUG_INFO_SECTION;
/* Output debugging information. */
- ASM_OUTPUT_SECTION (asm_out_file, secname);
+ named_section_flags (secname, SECTION_DEBUG, 1);
output_compilation_unit_header ();
output_die (die);
}
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
- dw2_asm_output_data_uleb128 (lineno, "Included from line number %d", lineno);
- dw2_asm_output_data_uleb128 (lookup_filename (filename), "Filename we just started");
+ dw2_asm_output_data_uleb128 (lineno, "Included from line number %d",
+ lineno);
+ dw2_asm_output_data_uleb128 (lookup_filename (filename),
+ "Filename we just started");
}
}
}
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
}
}
}
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
dw2_asm_output_data (1, DW_MACINFO_define, "Define macro");
dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
dw2_asm_output_nstring (buffer, -1, "The macro");
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro");
dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
dw2_asm_output_nstring (buffer, -1, "The macro");
ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
DEBUG_LINE_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, 0);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LOC_SECTION);
+ named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG, 1);
ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ABBREV_SECTION);
+ named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG, 1);
ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
- if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
- {
- ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
- }
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION);
+ named_section_flags (DEBUG_INFO_SECTION, SECTION_DEBUG, 1);
ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+ named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG, 1);
ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
DEBUG_MACINFO_SECTION_LABEL, 0);
ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
}
+
+ if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
+ {
+ text_section ();
+ ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
+ }
}
/* Output stuff that dwarf requires at the end of every file,
add_sibling_attributes (node->die);
/* Output a terminator label for the .text section. */
- ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION);
+ text_section ();
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, TEXT_END_LABEL, 0);
-#if 0
- /* Output a terminator label for the .data section. */
- ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, DATA_END_LABEL, 0);
-
- /* Output a terminator label for the .bss section. */
- ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0);
-#endif
-
/* Output the source line correspondence table. We must do this
even if there is no line information. Otherwise, on an empty
translation unit, we will generate a present, but empty,
examining the file. */
if (! DWARF2_ASM_LINE_DEBUG_INFO)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION);
+ named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG, 1);
output_line_info ();
}
output_comp_unit (comp_unit_die);
/* Output the abbreviation table. */
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ABBREV_SECTION);
+ named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG, 1);
output_abbrev_section ();
if (pubname_table_in_use)
{
/* Output public names table. */
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
+ named_section_flags (DEBUG_PUBNAMES_SECTION, SECTION_DEBUG, 1);
output_pubnames ();
}
if (fde_table_in_use)
{
/* Output the address range information. */
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
+ named_section_flags (DEBUG_ARANGES_SECTION, SECTION_DEBUG, 1);
output_aranges ();
}
if (have_location_lists)
{
/* Output the location lists info. */
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LOC_SECTION);
+ named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG, 1);
output_location_lists (die);
have_location_lists = 0;
}
/* Output ranges section if necessary. */
if (ranges_table_in_use)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_RANGES_SECTION);
+ named_section_flags (DEBUG_RANGES_SECTION, SECTION_DEBUG, 1);
output_ranges ();
}
/* Have to end the primary source file. */
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+ named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1);
dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
}
}
/* Determine if we're in the text section. */
extern int in_text_section PARAMS ((void));
-#ifdef EH_FRAME_SECTION_ASM_OP
-extern void eh_frame_section PARAMS ((void));
-#endif
-
#ifdef CTORS_SECTION_ASM_OP
extern void ctors_section PARAMS ((void));
#endif
/* Default target hook that outputs nothing to a stream. */
extern void no_asm_to_stream PARAMS ((FILE *));
+
+/* Flags controling properties of a section. */
+#define SECTION_CODE 1 /* contains code */
+#define SECTION_WRITE 2 /* data is writable */
+#define SECTION_DEBUG 4 /* contains debug data */
+#define SECTION_LINKONCE 8 /* is linkonce */
+#define SECTION_SMALL 16 /* contains "small data" */
+#define SECTION_BSS 32 /* contains zeros only */
+#define SECTION_FORGET 64 /* forget that we've entered the section */
+#define SECTION_MACH_DEP 128 /* subsequent bits reserved for target */
+
+extern void named_section_flags PARAMS ((const char *, unsigned int,
+ unsigned int));
+
+union tree_node;
+extern unsigned int default_section_type_flags PARAMS ((union tree_node *,
+ const char *, int));
+
+extern void default_no_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+extern void default_elf_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+extern void default_coff_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+extern void default_pe_asm_named_section PARAMS ((const char *, unsigned int,
+ unsigned int));
+
#define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
#define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream
+#ifdef TARGET_ASM_NAMED_SECTION
+#define TARGET_HAVE_NAMED_SECTIONS true
+#else
+#define TARGET_ASM_NAMED_SECTION default_no_named_section
+#define TARGET_HAVE_NAMED_SECTIONS false
+#endif
+
#define TARGET_ASM_OUT {TARGET_ASM_OPEN_PAREN, \
TARGET_ASM_CLOSE_PAREN, \
TARGET_ASM_FUNCTION_PROLOGUE, \
TARGET_ASM_FUNCTION_END_PROLOGUE, \
TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \
- TARGET_ASM_FUNCTION_EPILOGUE}
+ TARGET_ASM_FUNCTION_EPILOGUE, \
+ TARGET_ASM_NAMED_SECTION}
/* All in tree.c. */
#define TARGET_MERGE_DECL_ATTRIBUTES merge_decl_attributes
#define TARGET_INIT_BUILTINS default_init_builtins
#define TARGET_EXPAND_BUILTIN default_expand_builtin
+/* In varasm.c. */
+#ifndef TARGET_SECTION_TYPE_FLAGS
+#define TARGET_SECTION_TYPE_FLAGS default_section_type_flags
+#endif
+
/* The whole shebang. */
#define TARGET_INITIALIZER \
{ \
TARGET_SET_DEFAULT_TYPE_ATTRIBUTES, \
TARGET_INSERT_ATTRIBUTES, \
TARGET_INIT_BUILTINS, \
- TARGET_EXPAND_BUILTIN \
+ TARGET_EXPAND_BUILTIN, \
+ TARGET_SECTION_TYPE_FLAGS, \
+ TARGET_HAVE_NAMED_SECTIONS \
}
/* Output the assembler code for function exit. */
void (* function_epilogue) PARAMS ((FILE *, HOST_WIDE_INT));
+
+ /* Switch to an arbitrary section NAME with attributes as specified
+ by FLAGS. ALIGN specifies any known alignment requirements for
+ the section; 0 if the default should be used. */
+ void (* named_section) PARAMS ((const char *, unsigned int,
+ unsigned int));
} asm_out;
/* Given two decls, merge their attributes and return the result. */
struct rtx_def *subtarget,
enum machine_mode mode,
int ignore));
+
+ /* Given a decl, a section name, and whether the decl initializer
+ has relocs, choose attributes for the section. */
+ /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */
+ unsigned int (* section_type_flags) PARAMS ((tree, const char *, int));
+
+ /* True if arbitrary sections are supported. */
+ bool have_named_sections;
};
extern struct gcc_target targetm;
#include "dwarf2asm.h"
#include "integrate.h"
#include "debug.h"
+#include "target.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
debug_hooks = &dwarf2_debug_hooks;
#endif
-#ifndef ASM_OUTPUT_SECTION_NAME
- if (flag_function_sections)
+ if (! targetm.have_named_sections)
{
- warning ("-ffunction-sections not supported for this target.");
- flag_function_sections = 0;
- }
- if (flag_data_sections)
- {
- warning ("-fdata-sections not supported for this target.");
- flag_data_sections = 0;
+ if (flag_function_sections)
+ {
+ warning ("-ffunction-sections not supported for this target.");
+ flag_function_sections = 0;
+ }
+ if (flag_data_sections)
+ {
+ warning ("-fdata-sections not supported for this target.");
+ flag_data_sections = 0;
+ }
}
-#endif
if (flag_function_sections
&& (profile_flag || profile_block_flag))
#include "ggc.h"
#include "tm_p.h"
#include "debug.h"
+#include "target.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h" /* Needed for external data
static int const_str_htab_eq PARAMS ((const void *x, const void *y));
static void const_str_htab_del PARAMS ((void *));
static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int));
+static void resolve_unique_section PARAMS ((tree, int));
\f
static enum in_section { no_section, in_text, in_data, in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
-#ifdef EH_FRAME_SECTION_ASM_OP
- , in_eh_frame
-#endif
#ifdef EXTRA_SECTIONS
, EXTRA_SECTIONS
#endif
return in_section == in_data;
}
+/* Tell assembler to change to section NAME with attributes FLAGS. */
+
+void
+named_section_flags (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align;
+{
+ if (in_section != in_named || strcmp (name, in_named_name))
+ {
+ (* targetm.asm_out.named_section) (name, flags, align);
+
+ if (flags & SECTION_FORGET)
+ in_section = no_section;
+ else
+ {
+ in_named_name = ggc_strdup (name);
+ in_section = in_named;
+ }
+ }
+}
+
/* Tell assembler to change to section NAME for DECL.
If DECL is NULL, just switch to section NAME.
If NAME is NULL, get the name from DECL.
named_section (decl, name, reloc)
tree decl;
const char *name;
- int reloc ATTRIBUTE_UNUSED;
+ int reloc;
{
+ unsigned int flags;
+
if (decl != NULL_TREE && !DECL_P (decl))
abort ();
if (name == NULL)
name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
- if (in_section != in_named || strcmp (name, in_named_name))
- {
-#ifdef ASM_OUTPUT_SECTION_NAME
- ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc);
-#else
- /* Section attributes are not supported if this macro isn't provided -
- some host formats don't support them at all. The front-end should
- already have flagged this as an error. */
- abort ();
-#endif
+ flags = (* targetm.section_type_flags) (decl, name, reloc);
+ named_section_flags (name, flags, 0);
+}
- in_named_name = ggc_strdup (name);
- in_section = in_named;
- }
+/* If required, set DECL_SECTION_NAME to a unique name. */
+
+static void
+resolve_unique_section (decl, reloc)
+ tree decl;
+ int reloc;
+{
+ if (DECL_SECTION_NAME (decl) == NULL_TREE
+ && (flag_function_sections
+ || (targetm.have_named_sections
+ && DECL_ONE_ONLY (decl))))
+ UNIQUE_SECTION (decl, reloc);
}
#ifdef BSS_SECTION_ASM_OP
#endif /* BSS_SECTION_ASM_OP */
-#ifdef EH_FRAME_SECTION_ASM_OP
-void
-eh_frame_section ()
-{
- if (in_section != in_eh_frame)
- {
- fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP);
- in_section = in_eh_frame;
- }
-}
-#endif
-
/* Switch to the section for function DECL.
If DECL is NULL_TREE, switch to the text section.
#if defined (EXCEPTION_SECTION)
EXCEPTION_SECTION ();
#else
-#ifdef ASM_OUTPUT_SECTION_NAME
- named_section (NULL_TREE, ".gcc_except_table", 0);
-#else
- if (flag_pic)
+ if (targetm.have_named_sections)
+ named_section (NULL_TREE, ".gcc_except_table", 0);
+ else if (flag_pic)
data_section ();
else
readonly_data_section ();
#endif
-#endif
}
\f
/* Given NAME, a putative register name, discard any customary prefixes. */
if (CONSTANT_POOL_BEFORE_FUNCTION)
output_constant_pool (fnname, decl);
-#ifdef ASM_OUTPUT_SECTION_NAME
- /* If the function is to be put in its own section and it's not in a section
- already, indicate so. */
- if ((flag_function_sections
- && DECL_SECTION_NAME (decl) == NULL_TREE)
- || UNIQUE_SECTION_P (decl))
- UNIQUE_SECTION (decl, 0);
-#endif
-
+ resolve_unique_section (decl, 0);
function_section (decl);
/* Tell assembler to move to target machine's alignment for functions. */
}
}
-#ifdef ASM_OUTPUT_SECTION_NAME
- /* We already know that DECL_SECTION_NAME() == NULL. */
- if (flag_data_sections != 0 || UNIQUE_SECTION_P (decl))
- UNIQUE_SECTION (decl, 0);
-#endif
-
+ resolve_unique_section (decl, 0);
+
switch (destination)
{
#ifdef ASM_EMIT_BSS
else if (DECL_INITIAL (decl))
reloc = output_addressed_constants (DECL_INITIAL (decl));
-#ifdef ASM_OUTPUT_SECTION_NAME
- if ((flag_data_sections != 0 && DECL_SECTION_NAME (decl) == NULL_TREE)
- || UNIQUE_SECTION_P (decl))
- UNIQUE_SECTION (decl, reloc);
-#endif
-
/* Switch to the appropriate section. */
+ resolve_unique_section (decl, reloc);
variable_section (decl, reloc);
/* dbxout.c needs to know this. */
ggc_add_root (&const_str_htab, 1, sizeof const_str_htab,
mark_const_str_htab);
}
+
+/* Select a set of attributes for section NAME based on the properties
+ of DECL and whether or not RELOC indicates that DECL's initializer
+ might contain runtime relocations.
+
+ We make the section read-only and executable for a function decl,
+ read-only for a const data decl, and writable for a non-const data decl.
+
+ If the section has already been defined, to not allow it to have
+ different attributes, as (1) this is ambiguous since we're not seeing
+ all the declarations up front and (2) some assemblers (e.g. SVR4)
+ do not recoginize section redefinitions. */
+
+unsigned int
+default_section_type_flags (decl, name, reloc)
+ tree decl;
+ const char *name;
+ int reloc;
+{
+ static htab_t htab;
+ unsigned int flags;
+ unsigned int **slot;
+
+ /* The names we put in the hashtable will always be the unique
+ versions gived to us by the stringtable, so we can just use
+ their addresses as the keys. */
+ if (!htab)
+ htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL);
+
+ if (decl && TREE_CODE (decl) == FUNCTION_DECL)
+ flags = SECTION_CODE;
+ else if (decl && DECL_READONLY_SECTION (decl, reloc))
+ flags = 0;
+ else
+ flags = SECTION_WRITE;
+
+ if (decl && DECL_ONE_ONLY (decl))
+ flags |= SECTION_LINKONCE;
+
+ if (strcmp (name, ".bss") == 0
+ || strncmp (name, ".bss.", 5) == 0
+ || strncmp (name, ".gnu.linkonce.b.", 16) == 0
+ || strcmp (name, ".sbss") == 0
+ || strncmp (name, ".sbss.", 6) == 0
+ || strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
+ flags |= SECTION_BSS;
+
+ /* See if we already have an entry for this section. */
+ slot = (unsigned int **) htab_find_slot (htab, name, INSERT);
+ if (!*slot)
+ {
+ *slot = (unsigned int *) xmalloc (sizeof (unsigned int));
+ **slot = flags;
+ }
+ else
+ {
+ if (decl && **slot != flags)
+ error_with_decl (decl, "%s causes a section type conflict");
+ }
+
+ return flags;
+}
+
+/* Output assembly to switch to section NAME with attribute FLAGS.
+ Four variants for common object file formats. */
+
+void
+default_no_named_section (name, flags, align)
+ const char *name ATTRIBUTE_UNUSED;
+ unsigned int flags ATTRIBUTE_UNUSED;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ /* Some object formats don't support named sections at all. The
+ front-end should already have flagged this as an error. */
+ abort ();
+}
+
+void
+default_elf_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ char flagchars[8], *f = flagchars;
+ const char *type;
+
+ if (!(flags & SECTION_DEBUG))
+ *f++ = 'a';
+ if (flags & SECTION_WRITE)
+ *f++ = 'w';
+ if (flags & SECTION_CODE)
+ *f++ = 'x';
+ if (flags & SECTION_SMALL)
+ *f++ = 's';
+ *f = '\0';
+
+ if (flags & SECTION_BSS)
+ type = "nobits";
+ else
+ type = "progbits";
+
+ fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n",
+ name, flagchars, type);
+}
+
+void
+default_coff_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ char flagchars[8], *f = flagchars;
+
+ if (flags & SECTION_WRITE)
+ *f++ = 'w';
+ if (flags & SECTION_CODE)
+ *f++ = 'x';
+ *f = '\0';
+
+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
+}
+
+void
+default_pe_asm_named_section (name, flags, align)
+ const char *name;
+ unsigned int flags;
+ unsigned int align ATTRIBUTE_UNUSED;
+{
+ default_coff_asm_named_section (name, flags, align);
+
+ if (flags & SECTION_LINKONCE)
+ {
+ /* Functions may have been compiled at various levels of
+ optimization so we can't use `same_size' here.
+ Instead, have the linker pick one. */
+ fprintf (asm_out_file, "\t.linkonce %s\n",
+ (flags & SECTION_CODE ? "discard" : "same_size"));
+ }
+}