diff options
author | midipix <writeonce@midipix.org> | 2015-03-21 16:17:42 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2015-03-21 16:17:42 -0400 |
commit | 47407cf33ecab9f430fa663cbeb96016f64045f8 (patch) | |
tree | 6af8a30b9ce5e47025077022cc0ac58def2a584c /gcc/config | |
parent | eccacb0b973e23731121e17676e4ffee5c73c4de (diff) | |
download | cbb-gcc-4.6.4-47407cf33ecab9f430fa663cbeb96016f64045f8.tar.bz2 cbb-gcc-4.6.4-47407cf33ecab9f430fa663cbeb96016f64045f8.tar.xz |
midipix target implementation: initial commit.
signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/i386/midipix.c | 454 | ||||
-rw-r--r-- | gcc/config/i386/midipix.h | 375 | ||||
-rw-r--r-- | gcc/config/i386/midipix.opt | 70 | ||||
-rw-r--r-- | gcc/config/i386/midipix_crtbegin.c | 23 | ||||
-rw-r--r-- | gcc/config/i386/midipix_crtend.c | 23 | ||||
-rw-r--r-- | gcc/config/i386/midipix_unwind.c | 25 | ||||
-rw-r--r-- | gcc/config/i386/midipix_winnt_common.h | 54 | ||||
-rw-r--r-- | gcc/config/i386/t-midipix | 103 |
8 files changed, 1127 insertions, 0 deletions
diff --git a/gcc/config/i386/midipix.c b/gcc/config/i386/midipix.c new file mode 100644 index 000000000..412ebfcbb --- /dev/null +++ b/gcc/config/i386/midipix.c @@ -0,0 +1,454 @@ +/*****************************************************************************/ +/* */ +/* midipix target interfaces */ +/* */ +/* Copyright (C) 2014,2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "output.h" +#include "tree.h" +#include "flags.h" +#include "target.h" +#include "i386-protos.h" + +/* common specs */ +const int TARGET_NOP_FUN_DLLIMPORT = 0; +const int use_pe_aligned_common = 1; +const int flag_writable_rel_rdata = 0; + +/* target SEH providers */ +#define TARGET_SEH_WINNT (TARGET_NT64 && flag_unwind_tables) +#define TARGET_SEH_MIDIPIX (TARGET_NT32 && flag_unwind_tables) + +#undef TARGET_SEH_WINNT +#undef TARGET_SEH_MIDIPIX + +#define TARGET_SEH_WINNT (TARGET_NT64) +#define TARGET_SEH_MIDIPIX (TARGET_NT32) + +/* 64-bit seh provided by winnt */ +void winnt_x86_64_pe_seh_init(FILE *); +void winnt_x86_64_pe_seh_end_prologue(FILE *); +void winnt_x86_64_pe_seh_unwind_emit(FILE *, rtx); +void winnt_x86_64_pe_seh_emit_except_personality(rtx); +void winnt_x86_64_pe_seh_init_sections(void); + + +/* 32-bit seh provided by midipix */ +void midipix_i386_pe_seh_init(FILE *); +void midipix_i386_pe_seh_end_prologue(FILE *); +void midipix_i386_pe_seh_unwind_emit(FILE *, rtx); +void midipix_i386_pe_seh_emit_except_personality(rtx); +void midipix_i386_pe_seh_init_sections(void); + + +/* debugging */ +unsigned int midipix_dbx_get_register_number(unsigned int n) +{ + if (TARGET_NT64 ) + return dbx64_register_map[n]; + else if (write_symbols == DWARF2_DEBUG) + return svr4_dbx_register_map[n]; + else + return dbx_register_map[n]; +} + + +unsigned int midipix_dbx_get_dwarf_frame_register_number(unsigned int n) +{ + if (TARGET_NT64) + return dbx64_register_map[n]; + else + return svr4_dbx_register_map[n]; +} + + +void midipix_asm_output_dwarf_offset( + FILE * gas_exhaled, + unsigned size, + const char * label, + section * section __attribute__((unused))) +{ + #define PE_SIZE_IDENTIFIER 4 + #define PEP_SIZE_IDENTIFIER 8 + + extern void assemble_name (FILE *, const char *); + + if ((size == PE_SIZE_IDENTIFIER) || (size == PEP_SIZE_IDENTIFIER)) { + fputs ("\t.secrel32\t", gas_exhaled); + assemble_name(gas_exhaled, label); + + /* in PE32+, section relocation need to be zero-extended */ + if (size == PEP_SIZE_IDENTIFIER) + fputs ("\n\t.int\t0", gas_exhaled); + } else + gcc_unreachable(); +} + + +/* assembler labels */ +void midipix_asm_output_label_ref (FILE * gas_exhaled, const char * name) +{ + extern const char * user_label_prefix; + + /* in __fastcall labels the @ prefix is already present */ + if (*name != FASTCALL_PREFIX) + fputs(user_label_prefix, gas_exhaled); + + fputs(name, gas_exhaled); +} + + +void midipix_asm_generate_internal_label ( + char * strbuf, const char * prefix, unsigned long number) +{ + sprintf (strbuf, "*%s%s%ld", + LOCAL_LABEL_PREFIX, + prefix, + number); +} + + +void midipix_asm_declare_object_name(FILE * gas_exhaled, const char * name, tree decl) +{ + extern void assemble_name (FILE *, const char *); + extern void i386_pe_maybe_record_exported_symbol (tree, const char *, int); + + i386_pe_maybe_record_exported_symbol(decl, name, true); + assemble_name(gas_exhaled, name); + fputs (":\n", gas_exhaled); +} + + +void midipix_asm_drectve_section(void) +{ + extern FILE * asm_out_file; + extern section * in_section; + + in_section = (section *)0; + + fprintf (asm_out_file, "%s%s\n", + GAS_SECTION, + DRECTVE_SECTION_NAME); +} + + +int midipix_target_use_local_thunk_alias(tree decl) +{ + return !DECL_ONE_ONLY(decl); +} + + +void midipix_asm_output_external( + FILE * asmout __attribute__((unused)), + tree decl, + const char * name) +{ + if (TREE_CODE(decl) == FUNCTION_DECL) + i386_pe_record_external_function( + decl,name); +} + + +void midipix_asm_output_external_libcall (FILE * asmout, rtx fn) +{ + i386_pe_declare_function_type( + asmout, + XSTR(fn,0), + true); +} + + +void midipix_asm_output_def_from_decls( + FILE * asmout, + tree decl, + tree target) +{ + const char * sym; + + sym = IDENTIFIER_POINTER( + DECL_ASSEMBLER_NAME(decl)); + + i386_pe_maybe_record_exported_symbol( + decl,sym,false); + + if (TREE_CODE(decl) == FUNCTION_DECL) + i386_pe_declare_function_type( + asmout, + sym, + TREE_PUBLIC(decl)); + + ASM_OUTPUT_DEF( + asmout, + sym, + IDENTIFIER_POINTER(target)); +} + + +/* visibility */ +void midipix_i386_pe_assemble_visibility ( + tree decl __attribute__((unused)), + int visible __attribute__((unused))) +{ + /* todo: add the symbol to a special section (.hidden), + and teach the linker to not export symbols that are + listed under that section. */ +} + + + + +/* seh hook selectors */ +void midipix_seh_hook__pe_seh_init(FILE * f) +{ + if (TARGET_SEH_WINNT) + winnt_x86_64_pe_seh_init(f); + else if (TARGET_SEH_MIDIPIX) + midipix_i386_pe_seh_init(f); +} + + +void midipix_seh_hook__pe_seh_end_prologue(FILE * f) +{ + if (TARGET_SEH_WINNT) + winnt_x86_64_pe_seh_end_prologue(f); + else if (TARGET_SEH_MIDIPIX) + midipix_i386_pe_seh_end_prologue(f); +} + + +void midipix_seh_hook__pe_seh_unwind_emit(FILE * f, rtx r) +{ + if (TARGET_SEH_WINNT) + winnt_x86_64_pe_seh_unwind_emit(f,r); + else if (TARGET_SEH_MIDIPIX) + midipix_i386_pe_seh_unwind_emit(f,r); +} + + + +void midipix_seh_hook__pe_seh_emit_except_personality(rtx r) +{ + if (TARGET_SEH_WINNT) + winnt_x86_64_pe_seh_emit_except_personality(r); + else if (TARGET_SEH_MIDIPIX) + midipix_i386_pe_seh_emit_except_personality(r); +} + + +void midipix_seh_hook__pe_seh_init_sections(void) +{ + if (TARGET_SEH_WINNT) + winnt_x86_64_pe_seh_init_sections(); + else if (TARGET_SEH_MIDIPIX) + midipix_i386_pe_seh_init_sections(); +} + + + +/* 64-bit seh hooks (winnt) */ +void winnt_x86_64_pe_seh_init(FILE * f) +{ + i386_pe_seh_init(f); +} + + +void winnt_x86_64_pe_seh_end_prologue(FILE * f) +{ + i386_pe_seh_end_prologue(f); +} + + +void winnt_x86_64_pe_seh_unwind_emit(FILE * f, rtx r) +{ + i386_pe_seh_unwind_emit(f,r); +} + + +void winnt_x86_64_pe_seh_emit_except_personality(rtx r __attribute__((unused))) +{ + /* i386_pe_seh_emit_except_personality(r); */ +} + + +void winnt_x86_64_pe_seh_init_sections(void) +{ + /* i386_pe_seh_init_sections(); */ +} + + + +/* 32-bit seh hooks (midipix) */ +void midipix_i386_pe_seh_init(FILE * f __attribute__((unused))) +{ +} + + +void midipix_i386_pe_seh_end_prologue(FILE * f __attribute__((unused))) +{ +} + + +void midipix_i386_pe_seh_unwind_emit( + FILE * f __attribute__((unused)), + rtx r __attribute__((unused))) +{ +} + + +void midipix_i386_pe_seh_emit_except_personality(rtx r __attribute__((unused))) +{ +} + + +void midipix_i386_pe_seh_init_sections(void) +{ +} + + +section * midipix_i386_pe_function_section ( + tree decl, + enum node_frequency freq, + bool startup, + bool exit) +{ + extern section * default_function_section ( + tree decl, + enum node_frequency freq, + bool startup, + bool exit); + + const char * fname; + char * secname; + size_t size; + + bool weak; + section * asm_section; + + weak = (decl && DECL_WEAK (decl)); + + if (weak && DECL_ATTRIBUTES(decl) && lookup_attribute ( + "weak_import", + DECL_ATTRIBUTES(decl))) + weak = 0; + + fname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + + #ifdef MIDIPIX_TARGET_DEBUG + fputs ("\t# <", asm_out_file); + assemble_name (asm_out_file, fname); + fputs (": section>\n", asm_out_file); + #endif + + if (weak) { + #ifdef MIDIPIX_TARGET_DEBUG + fputs("\t# (weak symbol section)\n",asm_out_file); + #endif + + size = strlen(fname) + 6; /* .text$ */ + + if (!(secname = (char *)xmalloc(size))) + gcc_unreachable(); + + sprintf(secname,".text$%s",fname); + asm_section = get_named_section(decl, secname, 1); + free(secname); + } else if (decl) { + #ifdef MIDIPIX_TARGET_DEBUG + fputs("\t# (strong symbol section)\n",asm_out_file); + #endif + + asm_section = default_function_section(decl, freq, startup, exit); + } else { + fputs("\t# should never get here?\n",asm_out_file); + asm_section = (section *)0; + } + + #ifdef MIDIPIX_TARGET_DEBUG + fputs ("\t# </", asm_out_file); + assemble_name (asm_out_file, fname); + fputs (": section>\n", asm_out_file); + #endif + + return asm_section; +} + + +void midipix_i386_pe_start_function (FILE * gas_exhaled, const char *name, tree decl) +{ + #ifdef MIDIPIX_TARGET_DEBUG + fputs ("\t# <", gas_exhaled); + assemble_name (gas_exhaled, name); + fputs (">\n", gas_exhaled); + #endif + + i386_pe_start_function (gas_exhaled, name, decl); +} + + +void midipix_i386_pe_end_function (FILE * gas_exhaled, const char * name, tree decl) +{ + i386_pe_end_function (gas_exhaled, name, decl); + + #ifdef MIDIPIX_TARGET_DEBUG + fputs ("\t# </", gas_exhaled); + assemble_name (gas_exhaled, name); + fputs (">\n\n\n", gas_exhaled); + #endif +} + + +void midipix_i386_pe_asm_weaken_decl( + FILE * gas_exhaled, + tree decl, + const char * name, + const char * alias __attribute__((unused))) +{ + if ((decl) && DECL_EXTERNAL(decl)) { + #ifdef MIDIPIX_TARGET_DEBUG + fputs ("\t# (external weak symbol label)\n", gas_exhaled); + #endif + + fputs ("\t.weak\t", gas_exhaled); + assemble_name (gas_exhaled, name); + fputs ("\n", gas_exhaled); + } else { + #ifdef MIDIPIX_TARGET_DEBUG + fputs("\t# (normal weak symbol label)\n", gas_exhaled); + #endif + + /* write a patch for ld so that we can use .globl instead */ + fputs("\t.weak\t", gas_exhaled); + assemble_name (gas_exhaled, name); + fputs ("\n", gas_exhaled); + } +} + + +void midipix_i386_pe_asm_weaken_label(FILE * gas_exhaled, const char * name) +{ + midipix_i386_pe_asm_weaken_decl( + gas_exhaled, + (tree)0, + name, + (const char *)0); +} diff --git a/gcc/config/i386/midipix.h b/gcc/config/i386/midipix.h new file mode 100644 index 000000000..7aa61af25 --- /dev/null +++ b/gcc/config/i386/midipix.h @@ -0,0 +1,375 @@ +/*****************************************************************************/ +/* */ +/* midipix target definitions */ +/* */ +/* Copyright (C) 2014,2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +#include <stdio.h> +#include "coretypes.h" + + +/* identify targets */ +#define TARGET_NT64 (TARGET_64BIT) +#define TARGET_NT32 (!TARGET_64BIT) + + +/* target constraints */ +#undef TARGET_SEH +#define TARGET_SEH (flag_unwind_tables) + +#undef MAX_OFILE_ALIGNMENT +#define MAX_OFILE_ALIGNMENT (8 * (2 * 4096)) + +#define NT64_MAX_STACK_ALIGNMENT (8 * 16) +#define NT32_MAX_STACK_ALIGNMENT MAX_OFILE_ALIGNMENT + +#define NT64_STACK_BOUNDARY (8 * 16) +#define NT32_STACK_BOUNDARY BITS_PER_WORD + +#undef MAX_STACK_ALIGNMENT +#define MAX_STACK_ALIGNMENT (TARGET_NT64 \ + ? NT64_MAX_STACK_ALIGNMENT \ + : NT32_MAX_STACK_ALIGNMENT) + +#undef STACK_BOUNDARY +#define STACK_BOUNDARY (TARGET_NT64) \ + ? (NT64_STACK_BOUNDARY) \ + : (NT32_STACK_BOUNDARY) + +#undef STACK_CHECK_BUILTIN +#define STACK_CHECK_BUILTIN (1) + +#undef STACK_CHECK_STATIC_BUILTIN +#define STACK_CHECK_STATIC_BUILTIN (1) + +#undef DEFAULT_ABI +#define DEFAULT_ABI (TARGET_NT64) \ + ? MS_ABI \ + : SYSV_ABI + + +#undef MULTIPLE_SYMBOL_SPACES +#define MULTIPLE_SYMBOL_SPACES (1) + +#undef MS_AGGREGATE_RETURN +#define MS_AGGREGATE_RETURN (0) + +#undef DEFAULT_PCC_STRUCT_RETURN +#define DEFAULT_PCC_STRUCT_RETURN (0) + +#undef NO_PROFILE_COUNTERS +#define NO_PROFILE_COUNTERS (1) + +#undef NT_MANDATED_FLAG_PIC +#define NT_MANDATED_FLAG_PIC (TARGET_NT64) \ + ? (flag_pic ? 1 : 0 ) \ + : 0 + +#undef SUBTARGET_OVERRIDE_OPTIONS +#define SUBTARGET_OVERRIDE_OPTIONS do { \ + flag_pic = NT_MANDATED_FLAG_PIC; \ + } while (0) + +#undef PCC_BITFIELD_TYPE_MATTERS +#define PCC_BITFIELD_TYPE_MATTERS (1) + + +#define TARGET_OS_CPP_BUILTINS midipix_target_os_cpp_builtins +#define EXTRA_OS_CPP_BUILTINS midipix_extra_os_cpp_builtins + + +/* general target options */ +#undef TARGET_PECOFF +#define TARGET_PECOFF (1) + +#undef TARGET_EXECUTABLE_SUFFIX +#define TARGET_EXECUTABLE_SUFFIX "" + +#undef MATH_LIBRARY +#define MATH_LIBRARY "" + +#undef CHECK_STACK_LIMIT +#define CHECK_STACK_LIMIT (4096 - (8*32)) + +#undef TARGET_DLLIMPORT_DECL_ATTRIBUTES +#define TARGET_DLLIMPORT_DECL_ATTRIBUTES (1) + +#undef TARGET_POSIX_IO +#define TARGET_POSIX_IO (1) + +#undef TARGET_SUBTARGET_DEFAULT +#define TARGET_SUBTARGET_DEFAULT (MASK_ALIGN_DOUBLE \ + | MASK_STACK_PROBE \ + | MASK_80387 \ + | MASK_IEEE_FP \ + | MASK_FLOAT_RETURNS) + + +/* assembler options */ +#undef HAVE_GAS_PE_SECREL32_RELOC +#define HAVE_GAS_PE_SECREL32_RELOC (1) + +#undef HAVE_GAS_BALIGN_AND_P2ALIGN +#define HAVE_GAS_BALIGN_AND_P2ALIGN (1) + +#undef SUPPORTS_ONE_ONLY +#define SUPPORTS_ONE_ONLY (1) + +#undef GAS_SPACE +#define GAS_SPACE " " + +#undef GAS_TAB +#define GAS_TAB "\t" + +#undef GAS_SECTION +#define GAS_SECTION GAS_TAB ".section" GAS_SPACE + +#undef DRECTVE_SECTION_NAME +#define DRECTVE_SECTION_NAME ".drectve" + +#undef RODATA_SECTION_NAME +#define RODATA_SECTION_NAME ".rdata,\"r\"" + +#undef GAS_PE_ASM_SET_OP +#define GAS_PE_ASM_SET_OP "\t.set\t" + +#undef SET_ASM_OP +#define SET_ASM_OP GAS_PE_ASM_SET_OP + +#undef READONLY_DATA_SECTION_ASM_OP +#define READONLY_DATA_SECTION_ASM_OP GAS_SECTION RODATA_SECTION_NAME + +#undef TARGET_EMUTLS_VAR_SECTION_EMUTLS +#define TARGET_EMUTLS_VAR_SECTION_EMUTLS + + +/* debugging options */ +#undef PREFERRED_DEBUGGING_TYPE +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG + +#undef DWARF_FRAME_REGISTERS +#define DWARF_FRAME_REGISTERS (TARGET_NT64 ? 33 : 17) + +#undef DBX_DEBUGGING_INFO +#define DBX_DEBUGGING_INFO (1) + +#undef SDB_DEBUGGING_INFO +#define SDB_DEBUGGING_INFO (1) + +#undef DWARF2_DEBUGGING_INFO +#define DWARF2_DEBUGGING_INFO (1) + +#undef HAVE_ENABLE_EXECUTE_STACK +#define HAVE_ENABLE_EXECUTE_STACK (1) + +#undef CHECK_EXECUTE_STACK_ENABLED +#define CHECK_EXECUTE_STACK_ENABLED (1) + +#undef DBX_REGISTER_NUMBER +#define DBX_REGISTER_NUMBER(n) midipix_dbx_get_register_number(n) + +#undef DWARF_FRAME_REGNUM +#define DWARF_FRAME_REGNUM(n) midipix_dbx_get_dwarf_frame_register_number(n) + +#undef ASM_OUTPUT_DWARF_OFFSET +#define ASM_OUTPUT_DWARF_OFFSET midipix_asm_output_dwarf_offset + +/* assembler labels */ +#undef USER_LABEL_PREFIX +#define USER_LABEL_PREFIX (TARGET_NT64 ? "" : "_") + +#undef LOCAL_LABEL_PREFIX +#define LOCAL_LABEL_PREFIX (TARGET_NT64 ? "." : "") + +#undef LPREFIX +#define LPREFIX (TARGET_NT64 ? ".L" : "L") + +#undef ASM_COMMENT_START +#define ASM_COMMENT_START "\t#" + +#undef ASM_OUTPUT_LABELREF +#define ASM_OUTPUT_LABELREF midipix_asm_output_label_ref + +#undef ASM_GENERATE_INTERNAL_LABEL +#define ASM_GENERATE_INTERNAL_LABEL midipix_asm_generate_internal_label + +#undef ASM_DECLARE_OBJECT_NAME +#define ASM_DECLARE_OBJECT_NAME midipix_asm_declare_object_name + +#undef ASM_OUTPUT_DEF_FROM_DECLS +#define ASM_OUTPUT_DEF_FROM_DECLS midipix_asm_output_def_from_decls + +#undef ASM_OUTPUT_EXTERNAL +#define ASM_OUTPUT_EXTERNAL midipix_asm_output_external + +#undef ASM_OUTPUT_EXTERNAL_LIBCALL +#define ASM_OUTPUT_EXTERNAL_LIBCALL midipix_asm_output_external_libcall + +#undef TARGET_USE_LOCAL_THUNK_ALIAS_P +#define TARGET_USE_LOCAL_THUNK_ALIAS_P midipix_target_use_local_thunk_alias + +#undef drectve_section +#define drectve_section midipix_asm_drectve_section + + +/* common target hooks */ +#undef ASM_DECLARE_FUNCTION_NAME +#define ASM_DECLARE_FUNCTION_NAME midipix_i386_pe_start_function + +#undef ASM_DECLARE_FUNCTION_SIZE +#define ASM_DECLARE_FUNCTION_SIZE midipix_i386_pe_end_function + +#undef TARGET_ASM_ASSEMBLE_VISIBILITY +#define TARGET_ASM_ASSEMBLE_VISIBILITY midipix_i386_pe_assemble_visibility + +#undef TARGET_ASM_FILE_END +#define TARGET_ASM_FILE_END i386_pe_file_end + +#undef ASM_OUTPUT_ALIGNED_BSS +#define ASM_OUTPUT_ALIGNED_BSS asm_output_aligned_bss + +#undef ASM_OUTPUT_ALIGNED_DECL_COMMON +#define ASM_OUTPUT_ALIGNED_DECL_COMMON i386_pe_asm_output_aligned_decl_common + +#undef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section + +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section + +#undef TARGET_SECTION_TYPE_FLAGS +#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags + +#undef TARGET_MANGLE_ASSEMBLER_NAME +#define TARGET_MANGLE_ASSEMBLER_NAME i386_pe_mangle_assembler_name + +#undef SUBTARGET_ENCODE_SECTION_INFO +#define SUBTARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info + +#undef TARGET_VALID_DLLIMPORT_ATTRIBUTE_P +#define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P i386_pe_valid_dllimport_attribute_p + +#undef TARGET_CXX_ADJUST_CLASS_AT_DEFINITION +#define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition + +#undef SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME +#define SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name + +#undef TARGET_ASM_RELOC_RW_MASK +#define TARGET_ASM_RELOC_RW_MASK midipix_i386_pe_reloc_rw_mask + + +/* libgcc */ +#define __CXX_SEH__ (1) + +#define LIBGCC2_TF_CEXT q +#define LIBGCC2_TF_SIZE 113 + +#undef TF_SIZE +#define TF_SIZE LIBGCC2_TF_SIZE + +#undef LIBGCC2_HAS_TF_MODE +#define LIBGCC2_HAS_TF_MODE (1) + + +/* source compatibility: seh prototypes */ +extern void midipix_seh_hook__pe_seh_init(FILE *); +extern void midipix_seh_hook__pe_seh_end_prologue(FILE *); +extern void midipix_seh_hook__pe_seh_unwind_emit(FILE *, rtx); +extern void midipix_seh_hook__pe_seh_emit_except_personality(rtx); +extern void midipix_seh_hook__pe_seh_init_sections(void); + + +/* SEH hooks: 64-bit provided by winnt.c, 32-bit (to be) provided by midipix.c */ +#define TARGET_ASM_UNWIND_EMIT midipix_seh_hook__pe_seh_unwind_emit +#define TARGET_ASM_FUNCTION_END_PROLOGUE midipix_seh_hook__pe_seh_end_prologue +#define TARGET_ASM_EMIT_EXCEPT_PERSONALITY midipix_seh_hook__pe_seh_emit_except_personality +#define TARGET_ASM_INIT_SECTIONS midipix_seh_hook__pe_seh_init_sections +#define SUBTARGET_ASM_UNWIND_INIT midipix_seh_hook__pe_seh_init + + +/* target-specific definitions */ +#ifndef IN_TARGET_LIBRARY_BUILD + +#undef BIGGEST_FIELD_ALIGNMENT +#define BIGGEST_FIELD_ALIGNMENT (8 * __CHAR_BIT__) + +#undef ASM_WEAKEN_DECL +#define ASM_WEAKEN_DECL midipix_i386_pe_asm_weaken_decl + +#undef ASM_WEAKEN_LABEL +#define ASM_WEAKEN_LABEL midipix_i386_pe_asm_weaken_label + +#undef TARGET_ASM_FUNCTION_SECTION +#define TARGET_ASM_FUNCTION_SECTION midipix_i386_pe_function_section + + +/* forward declarations */ +extern void builtin_define_std (const char *); + +extern void midipix_asm_drectve_section (void); +extern void midipix_asm_generate_internal_label (char * strbuf, const char * prefix, unsigned long number); + +extern int midipix_target_use_local_thunk_alias(tree decl); +extern void midipix_i386_pe_assemble_visibility (tree decl, int visible); + +extern void midipix_asm_output_external (FILE * asmout, tree decl, const char * name); +extern void midipix_asm_output_def_from_decls (FILE * asmout, tree decl, tree target); +extern void midipix_asm_output_external_libcall (FILE * asmout, rtx fn); + +extern void midipix_asm_declare_object_name (FILE * asmout, const char * name, tree decl); +extern void midipix_i386_pe_start_function (FILE * asmout, const char * name, tree decl); +extern void midipix_i386_pe_end_function (FILE * asmout, const char * name, tree decl); +extern void midipix_asm_output_label_ref (FILE * asmout, const char * name); +extern void midipix_i386_pe_asm_weaken_label (FILE * asmout, const char * name); + +extern void midipix_i386_pe_asm_weaken_decl (FILE * asmout, tree decl, const char * name, const char * alias); +extern void midipix_asm_output_dwarf_offset (FILE * asmout, unsigned size, const char * label, section * section); + +extern unsigned int midipix_dbx_get_register_number (unsigned int n); +extern unsigned int midipix_dbx_get_dwarf_frame_register_number (unsigned int n); + +extern section * midipix_i386_pe_function_section( + tree decl, + enum node_frequency freq, + bool startup, + bool exit); + + +/* inlined functions */ +static inline void midipix_extra_os_cpp_builtins(void) +{ + if (TARGET_NT64) + builtin_define_std("__NT64"); + else + builtin_define_std("__NT32"); +} + +static inline void midipix_target_os_cpp_builtins(void) +{ + builtin_define_std("__NTAPI"); + builtin_define_std("__MIDIPIX"); + midipix_extra_os_cpp_builtins(); +} + +static inline int midipix_i386_pe_reloc_rw_mask (void) +{ + return 0; +} + +#endif diff --git a/gcc/config/i386/midipix.opt b/gcc/config/i386/midipix.opt new file mode 100644 index 000000000..a2c1fa259 --- /dev/null +++ b/gcc/config/i386/midipix.opt @@ -0,0 +1,70 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; midipix target directives ;; +;; ;; +;; Copyright (C) 2014,2015 Z. Gilboa ;; +;; ;; +;; This program is free software: you can redistribute it and/or modify ;; +;; it under the terms of the GNU General Public License as published by ;; +;; the Free Software Foundation, either version 3 of the License, or ;; +;; (at your option) any later version. ;; +;; ;; +;; This program is distributed in the hope that it will be useful, ;; +;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; +;; GNU General Public License for more details. ;; +;; ;; +;; You should have received a copy of the GNU General Public License ;; +;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +posix +Target +use interfaces from the posix namespace + +mposix +Target +always join or create a posix session + +mout-implib +Target +upon linking the dynamic library foo.so, generate an accompanying import library foo.lib.a + +moutput-def +Target +upon linking the dynamic library foo.so, generate a corresponding symbol definition file foo.so.def + +mntapi +Target +operate in a free-standing Native API environment + +mtty-console +Target +if started by a non-posix parent, create a new instance of /dev/ttydbg, and make that instance the controlling terminal of the current process + +mldso +Target +use a dynamic loader + +mldso-absolute-path +Target +use the dynamic loader located at an application-defined absolute path + +mldso-default-path +Target +use the dynamic loader located at C:\\midipix\\lib + +mldso-app-dir-only +Target +use the dynamic loader found in the same physical directory as the current process + +mldso-root-relative +Target +use the dynamic loader found in /lib under a root directory relative to the physical location of the current process + +mldso-kernel-driver +Target +load dynamic libraries via calls to a custom ldso kernel driver + +; Retain blank line above diff --git a/gcc/config/i386/midipix_crtbegin.c b/gcc/config/i386/midipix_crtbegin.c new file mode 100644 index 000000000..eae6f7c30 --- /dev/null +++ b/gcc/config/i386/midipix_crtbegin.c @@ -0,0 +1,23 @@ +/*****************************************************************************/ +/* */ +/* midipix_crtbegin.c: a standard start file for the midipix targets */ +/* */ +/* Copyright (C) 2014,2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +int __dso_handle = 0; +const long __EH_FRAME_BEGIN__ = 0; diff --git a/gcc/config/i386/midipix_crtend.c b/gcc/config/i386/midipix_crtend.c new file mode 100644 index 000000000..3f15e8827 --- /dev/null +++ b/gcc/config/i386/midipix_crtend.c @@ -0,0 +1,23 @@ +/*****************************************************************************/ +/* */ +/* midipix_crtend.c: a standard end file for the midipix targets */ +/* */ +/* Copyright (C) 2014,2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +/* required functionality provided by libc and the system call layer */ +typedef int dummy; diff --git a/gcc/config/i386/midipix_unwind.c b/gcc/config/i386/midipix_unwind.c new file mode 100644 index 000000000..40168a251 --- /dev/null +++ b/gcc/config/i386/midipix_unwind.c @@ -0,0 +1,25 @@ +/*****************************************************************************/ +/* */ +/* midipix unwind functionality */ +/* */ +/* Copyright (C) 2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +void * __gcc_personality_seh0(void * arg, ... ) +{ + return 0; +} diff --git a/gcc/config/i386/midipix_winnt_common.h b/gcc/config/i386/midipix_winnt_common.h new file mode 100644 index 000000000..e6eae2014 --- /dev/null +++ b/gcc/config/i386/midipix_winnt_common.h @@ -0,0 +1,54 @@ +/*****************************************************************************/ +/* */ +/* midipix common definitions and source-compatibility layer */ +/* */ +/* Copyright (C) 2014,2015 Z. Gilboa */ +/* */ +/* This program is free software: you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License as published by */ +/* the Free Software Foundation, either version 3 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* */ +/*****************************************************************************/ + +#ifndef MIDIPIX_WINNT_COMMON_H +#define MIDIPIX_WINNT_COMMON_H + +/* midipix: source-compatibility: fwritable-relocated-rdata */ +#ifndef IN_TARGET_LIBRARY_BUILD + extern const int flag_writable_rel_rdata; +#else + /* always off */ + const int x_flag_writable_rel_rdata = 0; + #define flag_writable_rel_rdata x_flag_writable_rel_rdata +#endif + + +/* midipix: source-compatibility: mpe-aligned-commons */ +#ifndef IN_TARGET_LIBRARY_BUILD + extern const int use_pe_aligned_common; +#else + /* always on */ + const int x_use_pe_aligned_common = 1; + #define use_pe_aligned_common x_use_pe_aligned_common +#endif + + +/* midipix: source-compatibility: mnop-fun-dllimport */ +#ifndef IN_TARGET_LIBRARY_BUILD + extern const int TARGET_NOP_FUN_DLLIMPORT; +#else + /* always off */ + const int x_TARGET_NOP_FUN_DLLIMPORT = 0; + #define TARGET_NOP_FUN_DLLIMPORT x_TARGET_NOP_FUN_DLLIMPORT +#endif + +#endif /* MIDIPIX_WINNT_COMMON_H */ diff --git a/gcc/config/i386/t-midipix b/gcc/config/i386/t-midipix new file mode 100644 index 000000000..0a05c343f --- /dev/null +++ b/gcc/config/i386/t-midipix @@ -0,0 +1,103 @@ +############################################################################### +## ## +## midipix target-specific build recipes ## +## ## +## Copyright (C) 2014,2015 Z. Gilboa ## +## ## +## This program is free software: you can redistribute it and/or modify ## +## it under the terms of the GNU General Public License as published by ## +## the Free Software Foundation, either version 3 of the License, or ## +## (at your option) any later version. ## +## ## +## This program is distributed in the hope that it will be useful, ## +## but WITHOUT ANY WARRANTY; without even the implied warranty of ## +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## +## GNU General Public License for more details. ## +## ## +## You should have received a copy of the GNU General Public License ## +## along with this program. If not, see <http://www.gnu.org/licenses/>. ## +## ## +############################################################################### + + +midipix_winnt_common.o: s-output $(srcdir)/config/i386/winnt.c \ + $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \ + $(TM_P_H) $(HASHTAB_H) $(GGC_H) $(LTO_STREAMER_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + --include=$(srcdir)/config/i386/midipix_winnt_common.h \ + $(srcdir)/config/i386/winnt.c -o midipix_winnt_common.o + + +midipix_winnt_cxx.o: $(srcdir)/config/i386/winnt-cxx.c \ + $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) $(TREE_H) flags.h \ + $(TM_P_H) $(HASHTAB_H) $(GGC_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + --include=$(srcdir)/config/i386/midipix_winnt_common.h \ + $(srcdir)/config/i386/winnt-cxx.c -o $@ + + +midipix_winnt_stubs.o: $(srcdir)/config/i386/winnt-stubs.c \ + $(CONFIG_H) $(SYSTEM_H) coretypes.h \ + $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \ + $(TM_P_H) $(HASHTAB_H) $(GGC_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/i386/winnt-stubs.c -o $@ + + +midipix.o: $(srcdir)/config/i386/midipix.c coretypes.h + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/i386/midipix.c -o $@ + +STMP_FIXINC = stmp-fixinc +LIMITS_H_TEST = true +CUSTOM_CRTSTUFF = yes + +SHLIB_EXT = .so +SHLIB_IMPLIB = @shlib_base_name@.lib.a +SHLIB_SOVERSION = 1 +SHLIB_SONAME = @shlib_base_name@$(EH_MODEL).so +SHLIB_MAP = @shlib_map_file@ +SHLIB_OBJS = @shlib_objs@ +SHLIB_DIR = @multilib_dir@ +SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@ +SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk +SHLIB_MKMAP_OPTS = -v pe_dll=libgcc_s$(EH_MODEL).so +SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver + + +SHLIB_LINK = $(GCC_FOR_TARGET) \ + $(LIBGCC2_CFLAGS) \ + -shared -mout-implib \ + -nodefaultlibs \ + -o $(SHLIB_DIR)/$(SHLIB_SONAME) \ + $(SHLIB_OBJS) \ + --sysroot=$$(cbb_sysroot_for_libgcc) + + +SHLIB_INSTALL = \ + $$(mkinstalldirs) \ + $$(DESTDIR)$$(SHLIB_DLLDIR) \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL); \ + $(INSTALL) \ + $(SHLIB_DIR)/$(SHLIB_SONAME) \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/$(SHLIB_IMPLIB) \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_IMPLIB); \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/crtbegin.o \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/crtbegin.o; \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/crtbeginS.o \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/crtbeginS.o; \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/crtbeginT.o \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/crtbeginT.o; \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/crtend.o \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/crtend.o; \ + $(INSTALL_DATA) \ + $(SHLIB_DIR)/crtendS.o \ + $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/crtendS.o; |