diff -crN gcc-4.8-20121230/config/gthr.m4 gcc-work/config/gthr.m4
*** gcc-4.8-20121230/config/gthr.m4	2012-10-15 15:10:30.000000000 +0200
--- gcc-work/config/gthr.m4	2013-01-07 10:14:04.620667900 +0100
***************
*** 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	2012-12-27 02:58:06.000000000 +0100
--- gcc-work/gcc/config/i386/i386.c	2013-01-07 10:14:04.636667900 +0100
***************
*** 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_RDOS)
+     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	2012-12-19 17:04:11.000000000 +0100
--- gcc-work/gcc/config/i386/i386.h	2013-01-07 10:43:07.612247200 +0100
***************
*** 519,524 ****
--- 519,527 ----
  #define MACHOPIC_INDIRECT 0
  #define MACHOPIC_PURE 0
  
+ /* For the RDOS  */
+ #define TARGET_RDOS 0
+ 
  /* For the Windows 64-bit ABI.  */
  #define TARGET_64BIT_MS_ABI (TARGET_64BIT && ix86_cfun_abi () == MS_ABI)
  
***************
*** 2081,2086 ****
--- 2084,2093 ----
     asm (SECTION_OP "\n\t"					\
  	"call " CRT_MKSTR(__USER_LABEL_PREFIX__) #FUNC "\n"	\
  	TEXT_SECTION_ASM_OP);
+ 
+ /* Default threshold for putting data in large sections
+    with x86-64 medium memory model */
+ #define DEFAULT_LARGE_SECTION_THRESHOLD 65536
  
  /* Which processor to tune code generation for.  */
  
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	2012-12-19 17:04:11.000000000 +0100
--- gcc-work/gcc/config/i386/i386.md	2013-01-07 10:14:04.644667900 +0100
***************
*** 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	2012-11-16 08:17:30.000000000 +0100
--- gcc-work/gcc/config/i386/i386.opt	2013-01-07 10:14:04.646667900 +0100
***************
*** 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	1970-01-01 01:00:00.000000000 +0100
--- gcc-work/gcc/config/i386/rdos.h	2013-01-07 10:38:29.596748600 +0100
***************
*** 0 ****
--- 1,24 ----
+ 
+ /* 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_RDOS
+ #define TARGET_RDOS 1
+ 
+ #undef DEFAULT_SECTION_THRESHOLD
+ #define DEFAULT_SECTION_THRESHOLD 16
+ 
+ #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/i386/rdos32.h gcc-work/gcc/config/i386/rdos32.h
*** gcc-4.8-20121230/gcc/config/i386/rdos32.h	1970-01-01 01:00:00.000000000 +0100
--- gcc-work/gcc/config/i386/rdos32.h	2013-01-07 10:37:24.281217700 +0100
***************
*** 0 ****
--- 1,15 ----
+ 
+ /* RDOS uses .exe suffix */
+ #undef TARGET_EXECUTABLE_SUFFIX
+ #define TARGET_EXECUTABLE_SUFFIX ".exe"
+ 
+ #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	2012-11-22 00:33:40.000000000 +0100
--- gcc-work/gcc/config.gcc	2013-01-07 10:36:47.446534600 +0100
***************
*** 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 i386/i386elf.h i386/rdos32.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"
  	;;
