[PATCH,i386][4.3][RFC] PIC Generation on windows/cygwin
Andrew Pinski
pinskia@physics.uc.edu
Sat Jan 27 23:29:00 GMT 2007
>
> *** gcc/config/i386/i386.c (revision 121238)
> --- gcc/config/i386/i386.c (working copy)
> *************** static void x86_64_elf_unique_section (t
> *** 1404,1409 ****
> --- 1404,1421 ----
> static section *x86_64_elf_select_section (tree decl, int reloc,
> unsigned HOST_WIDE_INT align)
> ATTRIBUTE_UNUSED;
> + #if TARGET_CYGMING
> + /* Support for position independent code on target cygming.
> + In position independent mode, references to static and global
> + symbols are generated as offsets relative to a base label. The same
> + base label is used for computing relative offsets of labels
> + in the address diff vector for a switch statement. There is
> + one base label in each function. */
> +
> + /* The base label used for all relative offsets in pic mode. */
> + static rtx base_label;
> + #endif
This is not really GC safe.
> + #if ! TARGET_CYGMING
> xops[1] = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);
> + #endif
Use:
if (!TARGET_CYGMING)
instead.
> + #if ! TARGET_CYGMING
> if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION)
> output_asm_insn ("add{l}\t{%1, %0|%0, %1}", xops);
> else
> output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %1+(.-%a2)}", xops);
> + #else
> + base_label = xops[2];
> + #endif
Likewise.
> + #if TARGET_CYGMING
> + addr = i386_pe_generate_imported_symbol_ref(addr);
> + new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOTOFF);
> + #else
> new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOT);
> + #endif
This one needs to stay #if because it uses a function from a non x86 generic
file.
> + #if ! TARGET_CYGMING
> fputs ("@GOTOFF", file);
> + #else
> + /* On target CYGMING, we interpret GOTOFF of a symbol
> + as the offset of the symbol from the PIC base label. */
> + putc ('-', file);
> + output_pic_addr_const (file, base_label, code);
> + #endif
Again if(!TARGET_CYGMING)
> + #if TARGET_CYGMING
> + else if (TARGET_CYGMING)
> + {
> + fprintf (file, "%s%s%d-%s%d\n",
> + ASM_LONG, LPREFIX, value, LPREFIX,
> + CODE_LABEL_NUMBER(XEXP(base_label,0)));
> + }
> + #endif
Don't need "#if TARGET_CYGMING" really.
> ! #if TARGET_CYGMING
> ! {
> ! /* On target CYGMING, there is no PLT. Convert
> ! the function address to a PIC reference. */
> ! rtx reg;
> ! reg = legitimize_pic_address (XEXP (fnaddr, 0), 0);
> ! XEXP (fnaddr, 0) = reg;
> ! }
> ! #endif
Again if (TARGET_CYGMING)
Thanks,
Andrew Pinski
More information about the Gcc-patches
mailing list