diff --git a/gcc/config.in b/gcc/config.in
index 3925a11..ae67c2b 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -959,9 +959,6 @@
 /* Define if your assembler and linker support .hidden. */
 #undef HAVE_GAS_HIDDEN
 
-/* Define if your system supports gnu indirect functions. */
-#undef HAVE_GNU_INDIRECT_FUNCTION
-
 /* Define if your assembler supports .lcomm with an alignment field. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GAS_LCOMM_WITH_ALIGNMENT
@@ -1062,6 +1059,12 @@
 #endif
 
 
+/* Define if your system supports gnu indirect functions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GNU_INDIRECT_FUNCTION
+#endif
+
+
 /* Define if using GNU ld. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GNU_LD
@@ -1296,6 +1299,12 @@
 #endif
 
 
+/* Define if you have prctl PR_SET_NAME */
+#ifndef USED_FOR_TARGET
+#undef HAVE_PRCTL_SET_NAME
+#endif
+
+
 /* Define to 1 if you have the `putchar_unlocked' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_PUTCHAR_UNLOCKED
diff --git a/gcc/configure b/gcc/configure
index e2c0a13..92edc13 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -8484,6 +8484,33 @@ done
 LIBS="$save_LIBS"
 CPPFLAGS="$save_CPPFLAGS"
 
+# check for prctl PR_SET_NAME
+if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run test program while cross compiling
+See \`config.log' for more details." "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/prctl.h>
+int main()
+{
+  return (prctl(PR_SET_NAME, "foo") == 0) ? 0 : 1;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+$as_echo "#define HAVE_PRCTL_SET_NAME 1" >>confdefs.h
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
 if test x$ac_cv_func_mbstowcs = xyes; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbstowcs works" >&5
 $as_echo_n "checking whether mbstowcs works... " >&6; }
@@ -17127,7 +17154,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17130 "configure"
+#line 17157 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17233,7 +17260,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17236 "configure"
+#line 17263 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 14690d3..51d5d88 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -991,6 +991,16 @@ int main()
 LIBS="$save_LIBS"
 CPPFLAGS="$save_CPPFLAGS"
 
+# check for prctl PR_SET_NAME
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <sys/prctl.h>
+int main()
+{
+  return (prctl(PR_SET_NAME, "foo") == 0) ? 0 : 1;
+}
+]])], AC_DEFINE(HAVE_PRCTL_SET_NAME, 1,
+	[Define if you have prctl PR_SET_NAME]))
+
 if test x$ac_cv_func_mbstowcs = xyes; then
   AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
 [    AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index e2fa975..36d0287 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -52,6 +52,10 @@ along with GCC; see the file COPYING3.  If not see
 #include <sys/mman.h>
 #endif
 
+#ifdef HAVE_PRCTL_SET_NAME
+#include <sys/prctl.h>
+#endif
+
 /* Handle opening elf files on hosts, such as Windows, that may use 
    text file handling that will break binary access.  */
 
@@ -2031,6 +2035,29 @@ lto_eh_personality (void)
   return lto_eh_personality_decl;
 }
 
+/* Set process name to NAME */
+
+static void
+set_process_name (const char *name ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_PRCTL_SET_NAME
+  prctl (PR_SET_NAME, name);
+#endif
+}
+
+/* Set the process name based on the LTO mode. */
+
+static void 
+lto_process_name (void)
+{
+  if (flag_lto)
+    set_process_name ("lto1-lto");
+  if (flag_wpa)
+    set_process_name ("lto1-wpa");
+  if (flag_ltrans)
+    set_process_name ("lto1-ltrans");
+}
+
 
 /* Main entry point for the GIMPLE front end.  This front end has
    three main personalities:
@@ -2055,6 +2082,8 @@ lto_eh_personality (void)
 void
 lto_main (int debug_p ATTRIBUTE_UNUSED)
 {
+  lto_process_name ();
+
   lto_init_reader ();
 
   /* Read all the symbols and call graph from all the files in the
