diff -ruN gcc-4.1.orig/config-ml.in gcc-4.1/config-ml.in --- gcc-4.1.orig/config-ml.in 2011-04-26 11:29:52.000000000 +1000 +++ gcc-4.1/config-ml.in 2011-08-06 10:24:23.000000000 +1000 @@ -892,13 +892,48 @@ fi fi - if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \ - --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \ - ${ac_configure_args} ${ml_srcdiroption} ; then - true - else - exit 1 - fi + case $(uname) in + MINGW32*) + # + # Work around bugs in MSYS sed or bash. The CC in + # ${ac_configure_args} overrides the CC built above + # I do not know if the CC should have been stripped + # before this script. It seems sed in MSYS does not + # handle: + # $ echo "'XX=hello' 'YY=world' 'CC=gcc -O3'" | sed -e "s/\'CC=.*\'//g" + # + tmp_IFS=$IFS + IFS="'" + tmp__ac_configure_args= + for o in ${ac_configure_args} + do + o=$(echo $o | sed -e 's/ *$//g') + case $o in + CC=*) ;; + '') ;; + *) tmp__ac_configure_args="${tmp__ac_configure_args} "\'$o\' ;; + esac + done + IFS=$tmp_IFS + + if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \ + --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \ + ${tmp__ac_configure_args} ${ml_srcdiroption} ; then + true + else + exit 1 + fi + ;; + *) + if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \ + --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \ + ${ac_configure_args} ${ml_srcdiroption} ; then + true + else + exit 1 + fi + ;; + esac cd ${ML_POPDIR} diff -ruN gcc-4.1.orig/gcc/DEV-PHASE gcc-4.1/gcc/DEV-PHASE --- gcc-4.1.orig/gcc/DEV-PHASE 2011-04-26 11:29:52.000000000 +1000 +++ gcc-4.1/gcc/DEV-PHASE 2011-08-06 10:24:25.000000000 +1000 @@ -0,0 +1 @@ +RTEMS (chrisj@rtems.org) NIOS2 gcc-4.1-11.0/newlib-1.19.0 diff -ruN gcc-4.1.orig/gcc/config/nios2/crti.asm gcc-4.1/gcc/config/nios2/crti.asm --- gcc-4.1.orig/gcc/config/nios2/crti.asm 2011-04-26 11:29:54.000000000 +1000 +++ gcc-4.1/gcc/config/nios2/crti.asm 2011-08-18 11:14:30.000000000 +1000 @@ -67,6 +67,11 @@ stw r16, 12(sp) stw fp, 8(sp) addi fp, sp, 8 + +#if !defined(__rtems__) +/* FIXME: Disabled for now. + * Causes undefined refs to _GLOBAL_OFFSET_TABLE_ + */ nextpc r22 #ifdef __nios2_6b__ 1: movhi20 r2, %hi20adj(_GLOBAL_OFFSET_TABLE_ - 1b) @@ -76,7 +81,7 @@ addi r2, r2, %lo(_GLOBAL_OFFSET_TABLE_ - 1b) #endif add r22, r22, r2 - +#endif .section ".fini" .align 2 @@ -94,6 +99,11 @@ stw r16, 12(sp) stw fp, 8(sp) addi fp, sp, 8 + +#if !defined(__rtems__) +/* FIXME: Disabled for now. + * Causes undefined refs to _GLOBAL_OFFSET_TABLE_ + */ nextpc r22 #ifdef __nios2_6b__ 1: movhi20 r2, %hi20adj(_GLOBAL_OFFSET_TABLE_ - 1b) @@ -102,7 +112,5 @@ 1: movhi r2, %hiadj(_GLOBAL_OFFSET_TABLE_ - 1b) addi r2, r2, %lo(_GLOBAL_OFFSET_TABLE_ - 1b) #endif - add r22, r22, r2 - - +#endif diff -ruN gcc-4.1.orig/gcc/config/nios2/nios2-protos.h gcc-4.1/gcc/config/nios2/nios2-protos.h --- gcc-4.1.orig/gcc/config/nios2/nios2-protos.h 2011-04-26 11:29:54.000000000 +1000 +++ gcc-4.1/gcc/config/nios2/nios2-protos.h 2011-08-06 10:24:23.000000000 +1000 @@ -88,3 +88,5 @@ extern int nios2_return_in_memory (tree); #endif /* TREE_CODE */ + +rtx nios2_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode); diff -ruN gcc-4.1.orig/gcc/config/nios2/rtems.h gcc-4.1/gcc/config/nios2/rtems.h --- gcc-4.1.orig/gcc/config/nios2/rtems.h 1970-01-01 10:00:00.000000000 +1000 +++ gcc-4.1/gcc/config/nios2/rtems.h 2011-08-17 17:06:39.000000000 +1000 @@ -0,0 +1,29 @@ +/* Definitions for rtems targeting a NIOS2 using ELF. + Copyright (C) 2011 Free Software Foundation, Inc. + Contributed by Chris Johns (chrisj@rtems.org). + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +/* Specify predefined symbols in preprocessor. */ + +#define TARGET_OS_CPP_BUILTINS() \ +do { \ + builtin_define ("__rtems__"); \ + builtin_define ("__USE_INIT_FINI__"); \ + builtin_assert ("system=rtems"); \ +} while (0) diff -ruN gcc-4.1.orig/gcc/config/nios2/t-rtems gcc-4.1/gcc/config/nios2/t-rtems --- gcc-4.1.orig/gcc/config/nios2/t-rtems 1970-01-01 10:00:00.000000000 +1000 +++ gcc-4.1/gcc/config/nios2/t-rtems 2011-08-18 06:03:59.000000000 +1000 @@ -0,0 +1,4 @@ +# Multilibs for NIOS2 RTEMS targets. + +# Use all. + diff -ruN gcc-4.1.orig/gcc/config.gcc gcc-4.1/gcc/config.gcc --- gcc-4.1.orig/gcc/config.gcc 2011-04-26 11:29:54.000000000 +1000 +++ gcc-4.1/gcc/config.gcc 2011-08-06 10:24:23.000000000 +1000 @@ -1447,6 +1447,10 @@ thread_file='posix' fi ;; +nios2-*-rtems*) + tm_file=" elfos.h ${tm_file} dbxelf.h nios2/rtems.h rtems.h" + tmake_file="${tmake_file} nios2/t-nios2 t-rtems nios2/t-rtems" + ;; nios2*-*-*) tm_file="elfos.h ${tm_file}" tmake_file="${tmake_file} nios2/t-nios2" diff -ruN gcc-4.1.orig/libiberty/strsignal.c gcc-4.1/libiberty/strsignal.c --- gcc-4.1.orig/libiberty/strsignal.c 2011-04-26 11:30:12.000000000 +1000 +++ gcc-4.1/libiberty/strsignal.c 2011-08-06 10:24:23.000000000 +1000 @@ -404,10 +404,10 @@ #ifndef HAVE_STRSIGNAL -const char * +char * strsignal (int signo) { - const char *msg; + char *msg; static char buf[32]; #ifndef HAVE_SYS_SIGLIST @@ -428,12 +428,12 @@ { /* In range, but no sys_siglist or no entry at this index. */ sprintf (buf, "Signal %d", signo); - msg = (const char *) buf; + msg = buf; } else { /* In range, and a valid message. Just return the message. */ - msg = (const char *) sys_siglist[signo]; + msg = (char *) sys_siglist[signo]; } return (msg); @@ -549,7 +549,7 @@ #ifndef HAVE_PSIGNAL void -psignal (unsigned signo, char *message) +psignal (int signo, const char *message) { if (signal_names == NULL) {