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