diff -crN gcc-4.8-20121230/config/gthr.m4 gcc-work/config/gthr.m4
*** gcc-4.8-20121230/config/gthr.m4	Mon Oct 15 15:10:30 2012
--- gcc-work/config/gthr.m4	Fri Jan  4 21:08:46 2013
***************
*** 21,26 ****
--- 21,27 ----
      tpf)	thread_header=config/s390/gthr-tpf.h ;;
      vxworks)	thread_header=config/gthr-vxworks.h ;;
      win32)	thread_header=config/i386/gthr-win32.h ;;
+     rdos)	thread_header=config/i386/gthr-rdos.h ;;
  esac
  AC_SUBST(thread_header)
  ])
diff -crN gcc-4.8-20121230/gcc/config/i386/i386.c gcc-work/gcc/config/i386/i386.c
*** gcc-4.8-20121230/gcc/config/i386/i386.c	Thu Dec 27 02:58:06 2012
--- gcc-work/gcc/config/i386/i386.c	Sun Jan  6 14:10:34 2013
***************
*** 3239,3244 ****
--- 3239,3246 ----
  	 DLL, and is essentially just as efficient as direct addressing.  */
        if (TARGET_64BIT && DEFAULT_ABI == MS_ABI)
  	ix86_cmodel = CM_SMALL_PIC, flag_pic = 1;
+       else if (TARGET_64BIT && TARGET_MEDIUM_PIC)
+     ix86_cmodel = CM_MEDIUM_PIC, flag_pic = 1;
        else if (TARGET_64BIT)
  	ix86_cmodel = flag_pic ? CM_SMALL_PIC : CM_SMALL;
        else
***************
*** 3919,3924 ****
--- 3921,3929 ----
        && !(target_flags_explicit & MASK_LONG_DOUBLE_64))
      target_flags |= MASK_LONG_DOUBLE_64;
  
+   if (ix86_section_threshold == 0)
+     ix86_section_threshold = DEFAULT_SECTION_THRESHOLD;
+ 
    /* Save the initial options in case the user does function specific
       options.  */
    if (main_args_p)
diff -crN gcc-4.8-20121230/gcc/config/i386/i386.h gcc-work/gcc/config/i386/i386.h
*** gcc-4.8-20121230/gcc/config/i386/i386.h	Wed Dec 19 17:04:12 2012
--- gcc-work/gcc/config/i386/i386.h	Sun Jan  6 13:24:26 2013
***************
*** 86,91 ****
--- 86,93 ----
  #define TARGET_LP64	TARGET_ABI_64
  #define TARGET_X32	TARGET_ABI_X32
  
+ #define TARGET_MEDIUM_PIC   0
+ 
  /* SSE4.1 defines round instructions */
  #define	OPTION_MASK_ISA_ROUND	OPTION_MASK_ISA_SSE4_1
  #define	TARGET_ISA_ROUND	((ix86_isa_flags & OPTION_MASK_ISA_ROUND) != 0)
***************
*** 790,795 ****
--- 792,801 ----
     it is the part of the ABI.  We shouldn't change it with -mavx.  */
  #define ATTRIBUTE_ALIGNED_VALUE 128
  
+ /* Default threshold for putting data in large sections with x86-64
+    medium memory model */
+ #define DEFAULT_SECTION_THRESHOLD 65536
+ 
  /* Decide whether a variable of mode MODE should be 128 bit aligned.  */
  #define ALIGN_MODE_128(MODE) \
   ((MODE) == XFmode || SSE_REG_MODE_P (MODE))
diff -crN gcc-4.8-20121230/gcc/config/i386/i386.md gcc-work/gcc/config/i386/i386.md
*** gcc-4.8-20121230/gcc/config/i386/i386.md	Wed Dec 19 17:04:12 2012
--- gcc-work/gcc/config/i386/i386.md	Sun Jan  6 13:17:36 2013
***************
*** 301,306 ****
--- 301,308 ----
     (R11_REG			40)
     (R12_REG			41)
     (R13_REG			42)
+    (R14_REG			43)
+    (R15_REG			44)
     (XMM8_REG			45)
     (XMM9_REG			46)
     (XMM10_REG			47)
diff -crN gcc-4.8-20121230/gcc/config/i386/i386.opt gcc-work/gcc/config/i386/i386.opt
*** gcc-4.8-20121230/gcc/config/i386/i386.opt	Fri Nov 16 08:17:30 2012
--- gcc-work/gcc/config/i386/i386.opt	Sun Jan  6 14:09:06 2013
***************
*** 141,147 ****
  Branches are this expensive (1-5, arbitrary units)
  
  mlarge-data-threshold=
! Target RejectNegative Joined UInteger Var(ix86_section_threshold) Init(65536)
  Data greater than given threshold will go into .ldata section in x86-64 medium model
  
  mcmodel=
--- 141,147 ----
  Branches are this expensive (1-5, arbitrary units)
  
  mlarge-data-threshold=
! Target RejectNegative Joined UInteger Var(ix86_section_threshold) Init(0)
  Data greater than given threshold will go into .ldata section in x86-64 medium model
  
  mcmodel=
diff -crN gcc-4.8-20121230/gcc/config/i386/rdos.h gcc-work/gcc/config/i386/rdos.h
*** gcc-4.8-20121230/gcc/config/i386/rdos.h	Thu Jan  1 01:00:00 1970
--- gcc-work/gcc/config/i386/rdos.h	Sun Jan  6 13:20:12 2013
***************
*** 0 ****
--- 1,22 ----
+ 
+ /* RDOS uses .exe suffix */
+ #undef TARGET_EXECUTABLE_SUFFIX
+ #define TARGET_EXECUTABLE_SUFFIX ".exe"
+ 
+ #undef REAL_PIC_OFFSET_TABLE_REGNUM
+ #define REAL_PIC_OFFSET_TABLE_REGNUM  R15_REG
+ 
+ #undef TARGET_MEDIUM_PIC
+ #define TARGET_MEDIUM_PIC           1
+ #define DEFAULT_SECTION_THRESHOLD    0x10
+ 
+ #define TARGET_OS_CPP_BUILTINS()                \
+   do                                            \
+     {                                           \
+         builtin_define ("__RDOS__");            \
+         builtin_assert ("system=rdos");         \
+     }                                           \
+   while (0)
+ 
+ /* RDOS headers are C++-aware (and often use C++).  */
+ #define NO_IMPLICIT_EXTERN_C
diff -crN gcc-4.8-20121230/gcc/config.gcc gcc-work/gcc/config.gcc
*** gcc-4.8-20121230/gcc/config.gcc	Thu Nov 22 00:33:40 2012
--- gcc-work/gcc/config.gcc	Fri Jan  4 21:08:46 2013
***************
*** 739,744 ****
--- 739,750 ----
    use_gcc_stdint=wrap
    tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC"
    ;;
+ *-*-rdos*)
+   case ${enable_threads} in
+     "" | yes | rdos) thread_file='rdos' ;;
+   esac
+   use_gcc_stdint=wrap
+   ;;
  *-*-solaris2*)
    # i?86-*-solaris2* needs to insert headers between cpu default and
    # Solaris 2 specific ones.
***************
*** 1205,1210 ****
--- 1211,1223 ----
  x86_64-*-elf*)
  	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
  	;;
+ i[34567]86-*-rdos*)
+     tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h"
+     ;;
+ x86_64-*-rdos*)
+     tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h  i386/x86-64.h i386/rdos.h"
+     tmake_file="i386/t-i386elf t-svr4"
+     ;;
  i[34567]86-*-freebsd*)
  	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/freebsd.h"
  	;;