diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 24791a4..19b5f1c 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1808,10 +1808,11 @@ s-mlib: $(srcdir)/genmultilib Makefile
 	    "$(MULTILIB_EXCLUSIONS)" \
 	    "$(MULTILIB_OSDIRNAMES)" \
 	    "$(MULTILIB_REQUIRED)" \
+	    "$(MULTILIB_REUSE)" \
 	    "@enable_multilib@" \
 	    > tmp-mlib.h; \
 	else \
-	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' no\
+	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' '' no\
 	    > tmp-mlib.h; \
 	fi
 	$(SHELL) $(srcdir)/../move-if-change tmp-mlib.h multilib.h
diff --git a/gcc/doc/fragments.texi b/gcc/doc/fragments.texi
index f53df29..eeaefb0 100644
--- a/gcc/doc/fragments.texi
+++ b/gcc/doc/fragments.texi
@@ -144,6 +144,28 @@ The @code{MULTILIB_REQUIRED} can be used together with
 @code{MULTILIB_OPTIONS} will be filtered by @code{MULTILIB_EXCEPTIONS}
 and then by @code{MULTILIB_REQUIRED}.
 
+@findex MULTILIB_REUSE
+@item MULTILIB_REUSE
+Sometimes it is desirable to reuse one existing multilib among different
+targets.  Such kind of reuse can minimize the number of multilib variants.
+Also for some targets it is better to reuse an existing multilib than to
+fall back on default multilib when there is no corresponding multilib.  To
+achieve this, just set @code{MULTILIB_REUSE} to be the list of reuse rules.
+A typical reuse rule is comprised of two parts connected by equality sign.
+The left part of the rule are the options used to build multilib and the right
+part are the options representing target that will reuse this multilib.  The
+equality sign in both parts should be replaced with period.
+The @code{MULTILIB_REUSE} is different from @code{MULTILIB_MATCHES} in that it
+sets up relations between two option sets rather than two options.  Here is an
+example to demo how we reuse libraries built in Thumb mode for applications built
+in ARM mode:
+@smallexample
+@code{MULTILIB_REUSE} = mthumb/march.armv7-r=marm/march.armv7-r
+@end smallexample
+
+The @code{MULTILIB_REUSE} is a complementary way to select multilib.  Only when the
+original way fails it will work.
+
 @findex MULTILIB_EXTRA_OPTS
 @item MULTILIB_EXTRA_OPTS
 Sometimes it is desirable that when building multiple versions of
diff --git a/gcc/gcc.c b/gcc/gcc.c
index b80af44..f425734 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -830,6 +830,7 @@ static const char *multilib_select;
 static const char *multilib_matches;
 static const char *multilib_defaults;
 static const char *multilib_exclusions;
+static const char *multilib_reuse;
 
 /* Check whether a particular argument is a default argument.  */
 
@@ -1220,6 +1221,7 @@ static struct spec_list static_specs[] =
   INIT_STATIC_SPEC ("multilib_matches",		&multilib_matches),
   INIT_STATIC_SPEC ("multilib_exclusions",	&multilib_exclusions),
   INIT_STATIC_SPEC ("multilib_options",		&multilib_options),
+  INIT_STATIC_SPEC ("multilib_reuse",		&multilib_reuse),
   INIT_STATIC_SPEC ("linker",			&linker_name_spec),
   INIT_STATIC_SPEC ("linker_plugin_file",	&linker_plugin_file_spec),
   INIT_STATIC_SPEC ("lto_wrapper",		&lto_wrapper_spec),
@@ -6272,6 +6274,13 @@ main (int argc, char **argv)
     obstack_1grow (&multilib_obstack, 0);
     multilib_exclusions = XOBFINISH (&multilib_obstack, const char *);
 
+    q = multilib_reuse_raw;
+    while ((p = *q++) != (char *) 0)
+      obstack_grow (&multilib_obstack, p, strlen (p));
+
+    obstack_1grow (&multilib_obstack, 0);
+    multilib_reuse = XOBFINISH (&multilib_obstack, const char *);
+
     need_space = FALSE;
     for (i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++)
       {
@@ -7474,10 +7483,16 @@ set_multilib_dir (void)
 
   first = 1;
   p = multilib_select;
+
+  /* Append multilib reuse rules if any.  With those rules, we can reuse
+     one multilib for certain different targets.  */
+  if (strlen(multilib_reuse) > 0)
+    p = concat (p, multilib_reuse, NULL);
+
   while (*p != '\0')
     {
-      /* Ignore newlines.  */
-      if (*p == '\n')
+      /* Ignore newlinesi and spaces.  */
+      if (*p == '\n' || *p == ' ')
 	{
 	  ++p;
 	  continue;
@@ -7490,8 +7505,8 @@ set_multilib_dir (void)
 	  if (*p == '\0')
 	    {
 	    invalid_select:
-	      fatal_error ("multilib select %qs is invalid",
-			   multilib_select);
+	      fatal_error ("multilib select %qs%qs is invalid",
+			   multilib_select, multilib_reuse);
 	    }
 	  ++p;
 	}
diff --git a/gcc/genmultilib b/gcc/genmultilib
index dc4751b..cab7fa1 100644
--- a/gcc/genmultilib
+++ b/gcc/genmultilib
@@ -84,6 +84,9 @@
 # This argument can be used together with MULTILIB_EXCEPTIONS and will take
 # effect after the MULTILIB_EXCEPTIONS.
 
+# The optional ninth argument defines rules to reuse one multilib among
+# different targets.
+
 # The last option should be "yes" if multilibs are enabled.  If it is not
 # "yes", all GCC multilib dir names will be ".".
 
@@ -104,7 +107,7 @@
 #   genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
 #		'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
 #		'' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
-#		'../lib64 ../lib32 alt' '' yes
+#		'../lib64 ../lib32 alt' '' '' yes
 # This produces:
 #   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
 #   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
@@ -133,7 +136,8 @@ extra=$5
 exclusions=$6
 osdirnames=$7
 multilib_required=$8
-enable_multilib=$9
+multilib_reuse=$9
+enable_multilib=${10}
 
 echo "static const char *const multilib_raw[] = {"
 
@@ -341,35 +345,36 @@ done
 optout=`echo ${optout} | sed -e 's/^ //'`
 echo "\".${defaultosdirname} ${optout};\","
 
-# Work over the list of combinations.  We have to translate each one
-# to use the directory names rather than the option names, we have to
-# include the information in matches, and we have to generate the
-# correct list of options and negations.
-for combo in ${combinations}; do
-  # Use the directory names rather than the option names.
+combo_to_dir()
+{
+  mcombo=""
+  mdirout=""
+  mosdirout=""
+
+  mcombo=$1
   if [ -n "${todirnames}" ]; then
-    dirout=`echo ${combo} | sed ${todirnames}`
+    mdirout=`echo ${mcombo} | sed ${todirnames}`
   else
-    dirout=`echo ${combo} | sed -e 's/=/-/g'`
+    mdirout=`echo ${mcombo} | sed -e 's/=/-/g'`
   fi
   # Remove the leading and trailing slashes.
-  dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`
+  mdirout=`echo ${mdirout} | sed -e 's|^/||' -e 's|/$||g'`
 
   # Use the OS directory names rather than the option names.
   if [ -n "${toosdirnames}" ]; then
-    osdirout=`echo ${combo} | sed ${toosdirnames}`
+    mosdirout=`echo ${mcombo} | sed ${toosdirnames}`
     # Remove the leading and trailing slashes.
-    osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
+    mosdirout=`echo ${mosdirout} | sed -e 's|^/||' -e 's|/$||g'`
     if [ "x${enable_multilib}" != xyes ]; then
-      dirout=".:${osdirout}"
+      mdirout=".:${mosdirout}"
       disable_multilib=yes
     else
-      case "${osdirout}" in
+      case "${mosdirout}" in
         !*)
-	  dirout=`echo ${osdirout} | sed 's/^!//'`
+	  mdirout=`echo ${mosdirout} | sed 's/^!//'`
 	  ;;
 	*)
-	  dirout="${dirout}:${osdirout}"
+	  mdirout="${mdirout}:${mosdirout}"
 	  ;;
       esac
     fi
@@ -381,21 +386,41 @@ for combo in ${combinations}; do
       exit 1
     fi
   fi
+  echo "${mdirout}"
+}
 
-  # Look through the options.  We must output each option that is
-  # present, and negate each option that is not present.
-  optout=
+# Function to look through the options and output each option that is present,
+# and negate each option that is not present.
+options_output()
+{
+  mcombo=""
+  moptout=""
+
+  mcombo=$1
   for set in ${options}; do
     setopts=`echo ${set} | sed -e 's_[/|]_ _g'`
     for opt in ${setopts}; do
-      if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
-	optout="${optout} ${opt}"
+      if expr "${mcombo} " : ".*/${opt}/.*" > /dev/null; then
+	moptout="${moptout} ${opt}"
       else
-	optout="${optout} !${opt}"
+	moptout="${moptout} !${opt}"
       fi
     done
   done
-  optout=`echo ${optout} | sed -e 's/^ //'`
+  moptout=`echo ${moptout} | sed -e 's/^ //'`
+  echo "${moptout}"
+}
+
+# Work over the list of combinations.  We have to translate each one
+# to use the directory names rather than the option names, we have to
+# include the information in matches, and we have to generate the
+# correct list of options and negations.
+for combo in ${combinations}; do
+  # Use the directory names rather than the option names.
+  dirout=$(combo_to_dir ${combo})
+  # Look through the options.  We must output each option that is
+  # present, and negate each option that is not present.
+  optout=$(options_output ${combo})
 
   # Output the line with all appropriate matches.
   dirout="${dirout}" optout="${optout}" ./tmpmultilib2
@@ -405,6 +430,29 @@ done
 echo "NULL"
 echo "};"
 
+# Output rules used for multilib reuse.
+echo ""
+echo "static const char *const multilib_reuse_raw[] = {"
+for rrule in ${multilib_reuse}; do
+  # The left part of the rule are the options we used to build multilib.
+  # The right part of the rule are the options that can reuse this multilib.
+  combo=`echo ${rrule} | sed -e 's/=.*$//' -e 's/\./=/g'`
+  copts=`echo ${rrule} | sed -e 's/^.*=//' -e 's/\./=/g'`
+  # We only care rule that has concrete multilib.
+  if expr "${combinations} " : ".*/${combo}/.*" > /dev/null; then
+    combo="/${combo}/"
+    dirout=$(combo_to_dir ${combo})
+    copts="/${copts}/"
+    optout=$(options_output ${copts})
+    # Output the line with all appropriate matches.
+    dirout="${dirout}" optout="${optout}" ./tmpmultilib2
+  fi
+done
+
+# Terminate the list of string.
+echo "NULL"
+echo "};"
+
 # Output all of the matches now as option and that is the same as that, with
 # a semicolon trailer.  Include all of the normal options as well.
 # Note, the format of the matches is reversed compared
