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-03 08:30:36.152649600 +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-04 13:39:39.746426400 +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_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,3930 ----
        && !(target_flags_explicit & MASK_LONG_DOUBLE_64))
      target_flags |= MASK_LONG_DOUBLE_64;
  
+ #ifdef TARGET_SECTION_THRESHOLD
+   ix86_section_threshold = TARGET_SECTION_THRESHOLD;
+ #endif
+ 
    /* 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-03 08:30:36.175651900 +0100
***************
*** 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)
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-04 13:41:21.409591700 +0100
***************
*** 0 ****
--- 1,19 ----
+ 
+ /* RDOS uses .exe suffix */
+ #undef TARGET_EXECUTABLE_SUFFIX
+ #define TARGET_EXECUTABLE_SUFFIX ".exe"
+ 
+ #undef TARGET_MEDIUM_PIC
+ #define TARGET_MEDIUM_PIC           1
+ #define TARGET_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	2012-11-22 00:33:40.000000000 +0100
--- gcc-work/gcc/config.gcc	2013-01-04 14:43:38.598930800 +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"
+     ;;
+ 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"
  	;;
