Commit 82c0e1a0 by Kai Tietz Committed by Kai Tietz

re PR target/52790 (Problems using x86_64-w64-mingw-w32-gfortran with mcmodel=large and medium)

	PR target/52790
	* config/i386/cygming.h (SUB_TARGET_RECORD_STUB): New sub-target macro.
	* config/i386/i386-protos.h (i386_pe_record_stub): Add new prototype.
	* config/i386/i386.c (legitimize_pe_coff_extern_decl): New static
	function.
	(legitimize_pe_coff_symbol): Likewise.
	(is_imported_p): New helper-function.
	(ix86_option_override_internal): Make MEDIUM_PIC the default code-model
	for Windows x64 targets.
	(ix86_expand_prologue): Optimize for pe-coff targets.
	(ix86_expand_split_stack_prologue): Adjust for pe-coff targets.
	(legitimate_pic_address_disp_p): Adjust for x64 pe-coff to support
	medium/large code-model.
	(legitimize_pic_address): Likewise.
	(legitimize_tls_address): Likewise.
	(ix86_expand_call): Likewise.
	(x86_output_mi_thunk): Likewise.
	(get_dllimport_decl): Add new beimport argument.
	(construct_plt_address): Don't assert for x64 pe-coff targets.
	* config/i386/i386.h (PIC_OFFSET_TABLE_REGNUM): Adjust for x64 pe-coff
	targets.
	(SYMBOL_FLAG_STUBVAR): New macro.
	(SYMBOL_REF_STUBVAR_P): Likewise.
	* config/i386/winnt.c (stub_list): New structure.
	(stub_head): New local variable.
	(i386_pe_record_stub): New function.
	(i386_pe_file_end): Emit refptr-stubs.

From-SVN: r197373
parent 09bb4c99
2013-04-02 Kai Tietz <ktietz@redhat.com>
PR target/52790
* config/i386/cygming.h (SUB_TARGET_RECORD_STUB): New sub-target macro.
* config/i386/i386-protos.h (i386_pe_record_stub): Add new prototype.
* config/i386/i386.c (legitimize_pe_coff_extern_decl): New static function.
(legitimize_pe_coff_symbol): Likewise.
(is_imported_p): New helper-function.
(ix86_option_override_internal): Make MEDIUM_PIC the default code-model
for Windows x64 targets.
(ix86_expand_prologue): Optimize for pe-coff targets.
(ix86_expand_split_stack_prologue): Adjust for pe-coff targets.
(legitimate_pic_address_disp_p): Adjust for x64 pe-coff to support
medium/large code-model.
(legitimize_pic_address): Likewise.
(legitimize_tls_address): Likewise.
(ix86_expand_call): Likewise.
(x86_output_mi_thunk): Likewise.
(get_dllimport_decl): Add new beimport argument.
(construct_plt_address): Don't assert for x64 pe-coff targets.
* config/i386/i386.h (PIC_OFFSET_TABLE_REGNUM): Adjust for x64 pe-coff
targets.
(SYMBOL_FLAG_STUBVAR): New macro.
(SYMBOL_REF_STUBVAR_P): Likewise.
* config/i386/winnt.c (stub_list): New structure.
(stub_head): New local variable.
(i386_pe_record_stub): New function.
(i386_pe_file_end): Emit refptr-stubs.
2013-04-02 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/56745
......
......@@ -474,5 +474,8 @@ do { \
#undef TARGET_ASM_ASSEMBLE_VISIBILITY
#define TARGET_ASM_ASSEMBLE_VISIBILITY i386_pe_assemble_visibility
#undef SUB_TARGET_RECORD_STUB
#define SUB_TARGET_RECORD_STUB i386_pe_record_stub
/* Static stack checking is supported by means of probes. */
#define STACK_CHECK_STATIC_BUILTIN 1
......@@ -260,6 +260,7 @@ extern void i386_pe_end_function (FILE *, const char *, tree);
extern void i386_pe_assemble_visibility (tree, int);
extern tree i386_pe_mangle_decl_assembler_name (tree, tree);
extern tree i386_pe_mangle_assembler_name (const char *);
extern void i386_pe_record_stub (const char *);
extern void i386_pe_seh_init (FILE *);
extern void i386_pe_seh_end_prologue (FILE *);
......
......@@ -1179,7 +1179,8 @@ enum target_cpu_default
#define REAL_PIC_OFFSET_TABLE_REGNUM BX_REG
#define PIC_OFFSET_TABLE_REGNUM \
((TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC) \
((TARGET_64BIT && (ix86_cmodel == CM_SMALL_PIC \
|| DEFAULT_ABI == MS_ABI)) \
|| !flag_pic ? INVALID_REGNUM \
: reload_completed ? REGNO (pic_offset_table_rtx) \
: REAL_PIC_OFFSET_TABLE_REGNUM)
......@@ -2379,6 +2380,10 @@ struct GTY(()) machine_function {
#define SYMBOL_REF_DLLEXPORT_P(X) \
((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_DLLEXPORT) != 0)
#define SYMBOL_FLAG_STUBVAR (SYMBOL_FLAG_MACH_DEP << 4)
#define SYMBOL_REF_STUBVAR_P(X) \
((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_STUBVAR) != 0)
extern void debug_ready_dispatch (void);
extern void debug_dispatch_window (int);
......
......@@ -646,8 +646,18 @@ struct GTY(()) export_list
int is_data; /* used to type tag exported symbols. */
};
/* Keep a list of stub symbols. */
struct GTY(()) stub_list
{
struct stub_list *next;
const char *name;
};
static GTY(()) struct export_list *export_head;
static GTY(()) struct stub_list *stub_head;
/* Assemble an export symbol entry. We need to keep a list of
these, so that we can output the export list at the end of the
assembly. We used to output these export symbols in each function,
......@@ -678,6 +688,30 @@ i386_pe_maybe_record_exported_symbol (tree decl, const char *name, int is_data)
export_head = p;
}
void
i386_pe_record_stub (const char *name)
{
struct stub_list *p;
if (!name || *name == 0)
return;
p = stub_head;
while (p != NULL)
{
if (p->name[0] == *name
&& !strcmp (p->name, name))
return;
p = p->next;
}
p = ggc_alloc_stub_list ();
p->next = stub_head;
p->name = name;
stub_head = p;
}
#ifdef CXX_WRAP_SPEC_LIST
/* Hash table equality helper function. */
......@@ -781,6 +815,30 @@ i386_pe_file_end (void)
(q->is_data ? ",data" : ""));
}
}
if (stub_head)
{
struct stub_list *q;
for (q = stub_head; q != NULL; q = q->next)
{
const char *name = q->name;
const char *oname;
if (name[0] == '*')
++name;
oname = name;
if (name[0] == '.')
++name;
if (strncmp (name, "refptr.", 7) != 0)
continue;
name += 7;
fprintf (asm_out_file, "\t.section\t.rdata$%s, \"dr\"\n"
"\t.globl\t%s\n"
"\t.linkonce\tdiscard\n", oname, oname);
fprintf (asm_out_file, "%s:\n\t.quad\t%s\n", oname, name);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment