This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

WinCE support in GAS


Hi Guys,

  Unless anyone has any objections I would like ot apply the following
  patch.  It adds support to GAS for toolchains targeted at Microsoft's
  Windows CE operating system.  At the moment these targets are
  mips-pe, sh-pe and arm-wince.

  Note - the ARM target used to be called arm-wince-pe, but it has
  been pointed out to me that this is wrong, and that it ought to be
  arm-wince instead.  I will be fixing the patches for the other parts
  of the toolchain that I have already sent out.

  Patch for other parts of binutils will follow.

Cheers
	Nick

2000-02-23  Nick Clifton  <nickc@cygnus.com>

	* configure: Add arm-wince, mips-pe and sh-pe targets.
	* configure: Regenerate.

	* config/obj-coff.h (COFF_WITH_PE): Define for mips-pe and
	sh-pe targets.
	(TARGET_FORMAT): Set to "pe-shl" for the sh-pe target and to
	"pe-mips" for the mips-pe target.

	* config/tc-arm.c (insns): Change displacement encoded in BL
	and B instructions if the target port is arm-wince.
	(do_ldst): Do not bias the relocation offset if the target
	port is arm-wince.
	(md_pcrel_from): Add in missing relocation offset bias if the
	target os arm-wince.

	* config/tc-mips.c (mips_target_format): Support COFF flavour.
	(md_begin): Disable -G support for mips-pe target.
	(md_apply_fix): Treat BFD_RELOC_RVA reloc as BFD_RELOC_32.
	* config/tc-mips.h (USE_GLOBAL_POINTER_OPT): Add support for
	COFF flavour.

	* config/tc-sh.c (md_begin): sh-pe target is little endian.
	* config/tc-sh.h (SUB_SEGMENT_ALIGN): If using a BFD
	assembler, just set the alignment to 4.

	* config/te-wince-pe.h: New file for WinCE targets.  Define
	TE_WINCE.

Index: configure
===================================================================
RCS file: /cvs/src//src/gas/configure,v
retrieving revision 1.17
diff -p -w -r1.17 configure
*** configure	2000/01/26 22:48:31	1.17
--- configure	2000/02/23 21:02:37
*************** for this_target in $target $canon_target
*** 2089,2094 ****
--- 2089,2095 ----
        arm-*-netbsd*)	                fmt=aout em=nbsd bfd_gas=yes ;;
        arm-*-oabi | thumb-*-oabi)        fmt=elf ;;
        arm-epoc-pe | thumb-epoc-pe)      fmt=coff em=epoc-pe ;;
+       arm-*-wince)         fmt=coff em=wince-pe bfd_gas=yes;;
        arm-*-pe | thumb-*-pe)            fmt=coff em=pe ;;
        arm-*-riscix*)	                fmt=aout em=riscix ;;
  
*************** EOF
*** 2202,2207 ****
--- 2203,2209 ----
        mips-*-osf*)          fmt=ecoff endian=little ;;
        mips-*-ecoff*)        fmt=ecoff ;;
        mips-*-ecoff*)        fmt=ecoff ;;
+       mips-*-pe*)           fmt=coff endian=little em=pe ;;
        mips-*-irix6*)	    fmt=elf ;;
        mips-*-irix5*)        fmt=elf ;;
        mips-*-irix*)         fmt=ecoff ;;
*************** EOF
*** 2250,2255 ****
--- 2252,2258 ----
  
        sh-*-elf*)	    fmt=elf ;;
        sh-*-coff*)           fmt=coff ;;
+       sh-*-pe*)             fmt=coff em=pe bfd_gas=yes;;
        sh-*-rtemself*)       fmt=elf ;;
        sh-*-rtems*)	    fmt=coff ;;
  
Index: configure.in
===================================================================
RCS file: /cvs/src//src/gas/configure.in,v
retrieving revision 1.15
diff -p -w -r1.15 configure.in
*** configure.in	2000/01/26 22:48:31	1.15
--- configure.in	2000/02/23 21:02:37
*************** changequote([,])dnl
*** 155,160 ****
--- 155,161 ----
        arm-*-netbsd*)	                fmt=aout em=nbsd bfd_gas=yes ;;
        arm-*-oabi | thumb-*-oabi)        fmt=elf ;;
        arm-epoc-pe | thumb-epoc-pe)      fmt=coff em=epoc-pe ;;
+       arm-*-wince)          fmt=coff em=wince-pe bfd_gas=yes;;
        arm-*-pe | thumb-*-pe)            fmt=coff em=pe ;;
        arm-*-riscix*)	                fmt=aout em=riscix ;;
  
*************** changequote([,])dnl
*** 266,271 ****
--- 267,273 ----
        mips-*-osf*)          fmt=ecoff endian=little ;;
        mips-*-ecoff*)        fmt=ecoff ;;
        mips-*-ecoff*)        fmt=ecoff ;;
+       mips-*-pe*)           fmt=coff endian=little em=pe ;;
        mips-*-irix6*)	    fmt=elf ;;
        mips-*-irix5*)        fmt=elf ;;
        mips-*-irix*)         fmt=ecoff ;;
*************** changequote([,])dnl
*** 310,315 ****
--- 312,318 ----
  
        sh-*-elf*)	    fmt=elf ;;
        sh-*-coff*)           fmt=coff ;;
+       sh-*-pe*)             fmt=coff em=pe bfd_gas=yes;;
        sh-*-rtemself*)       fmt=elf ;;
        sh-*-rtems*)	    fmt=coff ;;
  
Index: config/obj-coff.h
===================================================================
RCS file: /cvs/src//src/gas/config/obj-coff.h,v
retrieving revision 1.5
diff -p -w -r1.5 obj-coff.h
*** obj-coff.h	2000/01/31 19:13:47	1.5
--- obj-coff.h	2000/02/23 21:02:37
***************
*** 110,120 ****
--- 110,137 ----
  #endif
  
  #ifdef TC_SH
+ 
+ #ifdef TE_PE
+ #define COFF_WITH_PE
+ #endif
+ 
  #include "coff/sh.h"
+ 
+ #ifdef TE_PE
+ #define TARGET_FORMAT "pe-shl"
+ #else
  #define TARGET_FORMAT					\
    (shl							\
     ? (sh_small ? "coff-shl-small" : "coff-shl")		\
     : (sh_small ? "coff-sh-small" : "coff-sh"))
+ #endif
+ #endif
+ 
+ #ifdef TC_MIPS
+ #define COFF_WITH_PE
+ #include "coff/mipspe.h"
+ #undef  TARGET_FORMAT
+ #define TARGET_FORMAT "pe-mips"
  #endif
  
  #ifdef TC_M88K

Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-arm.c,v
retrieving revision 1.32
diff -p -w -r1.32 tc-arm.c
*** tc-arm.c	2000/01/31 22:14:50	1.32
--- tc-arm.c	2000/02/23 21:02:37
*************** static CONST struct asm_opcode insns[] =
*** 547,554 ****
--- 547,559 ----
    {"stm",   0x08000000, NULL,   stm_flags,   ARM_ANY,      do_ldmstm},
    {"ldm",   0x08100000, NULL,   ldm_flags,   ARM_ANY,      do_ldmstm},
    {"swi",   0x0f000000, NULL,   NULL,        ARM_ANY,      do_swi},
+ #ifdef TE_WINCE
+   {"bl",    0x0b000000, NULL,   NULL,        ARM_ANY,      do_branch},
+   {"b",     0x0a000000, NULL,   NULL,        ARM_ANY,      do_branch},
+ #else
    {"bl",    0x0bfffffe, NULL,   NULL,        ARM_ANY,      do_branch},
    {"b",     0x0afffffe, NULL,   NULL,        ARM_ANY,      do_branch},
+ #endif
    
  /* Pseudo ops */
    {"adr",   0x028f0000, NULL,   NULL,        ARM_ANY,      do_adr},
*************** do_ldst (str, flags)
*** 3020,3026 ****
--- 3025,3033 ----
          }
        else
          inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM;
+ #ifndef TE_WINCE
        inst.reloc.exp.X_add_number -= 8;  /* PC rel adjust */
+ #endif
        inst.reloc.pc_rel = 1;
        inst.instruction |= (REG_PC << 16);
        pre_inc = 1;
*************** md_pcrel_from (fixP)
*** 5206,5212 ****
--- 5215,5227 ----
        return (fixP->fx_where + fixP->fx_frag->fr_address) & ~3;
      }
  
+ #ifdef TE_WINCE
+   /* The pattern was adjusted to accomodate CE's off-by-one fixups,
+      so we un-adjust here to compensate for the accomodation.  */
+   return fixP->fx_where + fixP->fx_frag->fr_address + 8;
+ #else
    return fixP->fx_where + fixP->fx_frag->fr_address;
+ #endif
  }
  
  /* Round up a section size to the appropriate boundary. */

Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-mips.c,v
retrieving revision 1.11
diff -p -w -r1.11 tc-mips.c
*** tc-mips.c	2000/02/22 14:43:54	1.11
--- tc-mips.c	2000/02/23 21:02:38
*************** mips_target_format ()
*** 118,123 ****
--- 118,125 ----
        return target_big_endian ? "a.out-mips-big" : "a.out-mips-little";
      case bfd_target_ecoff_flavour:
        return target_big_endian ? "ecoff-bigmips" : ECOFF_LITTLE_FORMAT;
+     case bfd_target_coff_flavour:
+       return "pe-mips";
      case bfd_target_elf_flavour:
        return (target_big_endian
  	      ? (mips_64 ? "elf64-bigmips" : "elf32-bigmips")
*************** mips_target_format ()
*** 133,138 ****
--- 135,142 ----
  			    ? ".data" \
  			    : OUTPUT_FLAVOR == bfd_target_ecoff_flavour \
  			    ? ".rdata" \
+ 			    : OUTPUT_FLAVOR == bfd_target_coff_flavour \
+ 			    ? ".rdata" \
  			    : OUTPUT_FLAVOR == bfd_target_elf_flavour \
  			    ? ".rodata" \
  			    : (abort (), ""))
*************** md_begin ()
*** 848,853 ****
--- 852,866 ----
    int broken = 0;
    int mips_isa_from_cpu;
  
+   /* GP relative stuff not working for PE */
+   if (strncmp (TARGET_OS, "pe", 2) == 0
+       && g_switch_value != 0)
+     {
+       if (g_switch_seen)
+ 	as_bad (_("-G not supported in this configuration."));
+       g_switch_value = 0;
+     }
+ 
    cpu = TARGET_CPU;
    if (strcmp (cpu + (sizeof TARGET_CPU) - 3, "el") == 0)
      {
*************** md_apply_fix (fixP, valueP)
*** 9645,9650 ****
--- 9658,9664 ----
  	}
        break;
  
+     case BFD_RELOC_RVA:
      case BFD_RELOC_32:
        /* If we are deleting this reloc entry, we must fill in the
  	 value now.  This can happen if we have a .word which is not

Index: config/tc-mips.h
===================================================================
RCS file: /cvs/src//src/gas/config/tc-mips.h,v
retrieving revision 1.3
diff -p -w -r1.3 tc-mips.h
*** tc-mips.h	2000/01/14 17:58:29	1.3
--- tc-mips.h	2000/02/23 21:02:38
*************** extern void md_mips_end PARAMS ((void));
*** 142,147 ****
--- 142,148 ----
  #define md_end()	md_mips_end()
  
  #define USE_GLOBAL_POINTER_OPT	(OUTPUT_FLAVOR == bfd_target_ecoff_flavour \
+ 				 || OUTPUT_FLAVOR == bfd_target_coff_flavour \
  				 || OUTPUT_FLAVOR == bfd_target_elf_flavour)
  
  extern void mips_pop_insert PARAMS ((void));

Index: config/tc-sh.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-sh.c,v
retrieving revision 1.5
diff -p -w -r1.5 tc-sh.c
*** tc-sh.c	2000/02/17 00:33:36	1.5
--- tc-sh.c	2000/02/23 21:02:38
*************** md_begin ()
*** 209,214 ****
--- 209,218 ----
    if (! shl)
      target_big_endian = 1;
  
+ #ifdef TE_PE
+   target_big_endian = 0;
+ #endif
+ 
    target_arch = arch_sh1_up & ~(sh_dsp ? arch_sh3e_up : arch_sh_dsp_up);
    valid_arch = target_arch;
  
*************** DEFUN (md_undefined_symbol, (name),
*** 1678,1683 ****
--- 1682,1688 ----
  }
  
  #ifdef OBJ_COFF
+ #ifndef BFD_ASSEMBLER
  
  void
  DEFUN (tc_crawl_symbol_chain, (headers),
*************** DEFUN (tc_headers_hook, (headers),
*** 1693,1698 ****
--- 1698,1704 ----
    printf (_("call to tc_headers_hook \n"));
  }
  
+ #endif
  #endif
  
  /* Various routines to kill one day */
Index: config/tc-sh.h
===================================================================
RCS file: /cvs/src//src/gas/config/tc-sh.h,v
retrieving revision 1.3
diff -p -w -r1.3 tc-sh.h
*** tc-sh.h	2000/02/17 00:33:36	1.3
--- tc-sh.h	2000/02/23 21:02:38
*************** extern void sh_coff_reloc_mangle
*** 129,134 ****
--- 129,137 ----
  #define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag)
  extern int tc_coff_sizemachdep PARAMS ((fragS *));
  
+ #ifdef BFD_ASSEMBLER
+ #define SUB_SEGMENT_ALIGN(SEG) 4
+ #else
  /* We align most sections to a 16 byte boundary.  */
  #define SUB_SEGMENT_ALIGN(SEG)					\
    (strncmp (obj_segment_name (SEG), ".stabstr", 8) == 0		\
*************** extern int tc_coff_sizemachdep PARAMS ((
*** 138,143 ****
--- 141,147 ----
         || strcmp (obj_segment_name (SEG), ".dtors") == 0)	\
        ? 2							\
        : (sh_small ? 2 : 4)))
+ #endif
  
  #endif /* OBJ_COFF */
  
Index: config/te-wince-pe.h
===================================================================
RCS file: te-wince-pe.h
diff -N te-wince-pe.h
*** /dev/null	Tue May  5 13:32:27 1998
--- te-wince-pe.h	Wed Feb 23 13:02:40 2000
***************
*** 0 ****
--- 1,2 ----
+ #define TE_WINCE
+ #include "te-pe.h"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]