From 7c3694d44f6b88ed950f7d78a60c7c738d66a99b Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 26 Feb 2019 17:55:00 -0500 Subject: midipix targets: .gotrefs entry generation: revise abi, account for .linkonce. --- gcc/config/i386/midipix.c | 58 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/gcc/config/i386/midipix.c b/gcc/config/i386/midipix.c index 022f016a0..01f40c5a5 100644 --- a/gcc/config/i386/midipix.c +++ b/gcc/config/i386/midipix.c @@ -579,7 +579,7 @@ bool midipix_asm_assemble_integer(rtx x, unsigned int size, int aligned_p) section * sect; const char * name; const char * ptrsize; - const char * rvapad; + const char * secname; /* filter out c++ constructors */ if (flag_assume_static_linking) @@ -611,16 +611,9 @@ bool midipix_asm_assemble_integer(rtx x, unsigned int size, int aligned_p) if (!falt || (visibility != VISIBILITY_DEFAULT)) return default_assemble_integer(x,size,aligned_p); - /* name, ptrsize, rvapad, sect */ - name = XSTR(xref,0); - - if (TARGET_64BIT) { - ptrsize = winnt_ptrsize_quad; - rvapad = "\t.long 0\n"; - } else { - ptrsize = winnt_ptrsize_long; - rvapad = ""; - }; + /* name, ptrsize, sect */ + name = XSTR(xref,0); + ptrsize = TARGET_64BIT ? winnt_ptrsize_quad : winnt_ptrsize_long; sect = xoff ? data_section @@ -650,18 +643,49 @@ bool midipix_asm_assemble_integer(rtx x, unsigned int size, int aligned_p) fputs(GOTREFS_SECTION_NAME,asm_out_file); fputs("\n",asm_out_file); - /* back reference */ + /* back reference: section name */ + if (!in_section) + gcc_unreachable(); + + switch (SECTION_STYLE(in_section)) { + case SECTION_NAMED: + secname = (const char *)in_section->named.name; + break; + + case SECTION_UNNAMED: + if (in_section->common.flags & SECTION_BSS) + gcc_unreachable(); + + else if (in_section->common.flags & SECTION_CODE) + gcc_unreachable(); + + else if (in_section->common.flags & SECTION_LINKONCE) + gcc_unreachable(); + + else if (in_section->common.flags & SECTION_WRITE) + secname = ".data"; + + else + secname = ".rdata"; + + break; + + default: + gcc_unreachable(); + } + + /* back reference: section rva */ fputs("\t.rva",asm_out_file); - fputs("\t" "1b" "\n",asm_out_file); - fputs(rvapad,asm_out_file); + fprintf(asm_out_file,"\t%s\n",secname); + + /* back reference: in-section offset */ + fprintf(asm_out_file,"\t.long\t" "1b - %s" "\n",secname); /* sym reference */ fputs("\t.rva",asm_out_file); fputs("\t" "__imp_",asm_out_file); assemble_name(asm_out_file,name); - fputs("\n",asm_out_file); - fputs(rvapad,asm_out_file); - fputs("\n",asm_out_file); + fputs("\n\n",asm_out_file); /* re-establish current section */ midipix_asm_reestablish_section(asm_out_file,sect); -- cgit v1.2.3