fa3bfd
commit 08c6e95234c60a5c2f37532d1111acf084f39345
fa3bfd
Author: Florian Weimer <fweimer@redhat.com>
fa3bfd
Date:   Thu Jan 11 13:13:28 2018 +0100
fa3bfd
fa3bfd
    csu: Update __libgcc_s_init comment
fa3bfd
    
fa3bfd
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
fa3bfd
fa3bfd
commit f993b8754080ac7572b692870e926d8b493db16c
fa3bfd
Author: Florian Weimer <fweimer@redhat.com>
fa3bfd
Date:   Wed Jan 10 13:18:04 2018 +0100
fa3bfd
fa3bfd
    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
fa3bfd
    
fa3bfd
    Disabling lazy binding reduces stack usage during unwinding.
fa3bfd
    
fa3bfd
    Note that RTLD_NOW only makes a difference if libgcc.so has not
fa3bfd
    already been loaded, so this is only a partial fix.
fa3bfd
    
fa3bfd
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
fa3bfd
fa3bfd
Index: glibc-2.17-c758a686/nptl/sysdeps/pthread/unwind-forcedunwind.c
fa3bfd
===================================================================
fa3bfd
--- glibc-2.17-c758a686.orig/nptl/sysdeps/pthread/unwind-forcedunwind.c
fa3bfd
+++ glibc-2.17-c758a686/nptl/sysdeps/pthread/unwind-forcedunwind.c
fa3bfd
@@ -51,7 +51,7 @@ pthread_cancel_init (void)
fa3bfd
       return;
fa3bfd
     }
fa3bfd
 
fa3bfd
-  handle = __libc_dlopen (LIBGCC_S_SO);
fa3bfd
+  handle = __libc_dlopen_mode (LIBGCC_S_SO, RTLD_NOW | __RTLD_DLOPEN);
fa3bfd
 
fa3bfd
   if (handle == NULL
fa3bfd
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
fa3bfd
Index: glibc-2.17-c758a686/sysdeps/gnu/unwind-resume.c
fa3bfd
===================================================================
fa3bfd
--- glibc-2.17-c758a686.orig/sysdeps/gnu/unwind-resume.c
fa3bfd
+++ glibc-2.17-c758a686/sysdeps/gnu/unwind-resume.c
fa3bfd
@@ -35,12 +35,17 @@ init (void)
fa3bfd
   void *resume, *personality;
fa3bfd
   void *handle;
fa3bfd
 
fa3bfd
-  handle = __libc_dlopen (LIBGCC_S_SO);
fa3bfd
+  /* Use RTLD_NOW here for consistency with pthread_cancel_init.
fa3bfd
+     RTLD_NOW will rarely make a difference here because unwinding is
fa3bfd
+     already in progress, so libgcc_s.so has already been loaded if
fa3bfd
+     its unwinder is used.  */
fa3bfd
+  handle = __libc_dlopen_mode (LIBGCC_S_SO, RTLD_NOW | __RTLD_DLOPEN);
fa3bfd
 
fa3bfd
   if (handle == NULL
fa3bfd
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
fa3bfd
       || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
fa3bfd
-    __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
fa3bfd
+    __libc_fatal (LIBGCC_S_SO
fa3bfd
+		  " must be installed for unwinding to work\n");
fa3bfd
 
fa3bfd
   libgcc_s_resume = resume;
fa3bfd
   libgcc_s_personality = personality;