diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-04 01:31:41 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-04 01:31:41 +0000 |
commit | 2cb4ac60aa91b7ddb31c57536cdcb167978c4a7f (patch) | |
tree | f3a177e73b80eca5619e6a8d303a81b56c901052 /gcc/config/i386/winnt.c | |
parent | 2644ae20290060e1a751b1d361bd32abe693d97f (diff) | |
download | gcc-2cb4ac60aa91b7ddb31c57536cdcb167978c4a7f.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44623 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/i386/winnt.c')
-rw-r--r-- | gcc/config/i386/winnt.c | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 2d85b66930e..ff13c3863b7 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "tm_p.h" #include "toplev.h" +#include "hashtab.h" /* i386/PE specific attribute support. @@ -55,7 +56,7 @@ void i386_pe_mark_dllimport PARAMS ((tree)); int i386_pe_valid_decl_attribute_p (decl, attributes, attr, args) tree decl; - tree attributes; + tree attributes ATTRIBUTE_UNUSED; tree attr; tree args; { @@ -455,6 +456,99 @@ i386_pe_unique_section (decl, reloc) 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")); + } +} /* The Microsoft linker requires that every function be marked as DT_FCN. When using gas on cygwin, we must emit appropriate .type |