local-dlfptr
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Wed, 29 Nov 2017 03:00:21 +0000 (03:00 +0000)
committerPeter Michael Green <plugwash@raspbian.org>
Wed, 29 Nov 2017 03:00:21 +0000 (03:00 +0000)
Gbp-Pq: Topic any
Gbp-Pq: Name local-dlfptr.diff

elf/dl-fptr.c
sysdeps/generic/dl-fptr.h

index bf8ae43b51693ea14029447a59d43eef3698fa58..0c52cc82818eb851ab3e3669e5efe8ef4a8b5788 100644 (file)
@@ -56,7 +56,12 @@ static struct local
   }
 local =
   {
+#ifndef SHARED
     .root = &local.boot_table,
+#else
+    /* Address of .boot_table is not known until runtime.  */
+    .root = 0,
+#endif
     .npages = 2,
     .boot_table =
       {
@@ -93,6 +98,17 @@ new_fdesc_table (struct local *l, size_t *size)
   return new_table;
 }
 
+/* Must call _dl_fptr_init before using any other function.  */
+void
+_dl_fptr_init (void)
+{
+  struct local *l;
+
+  ELF_MACHINE_LOAD_ADDRESS (l, local);
+  /* Initialize root once.  */
+  if (__builtin_expect (l->root == 0, 0))
+    l->root = &l->boot_table;
+}
 
 static ElfW(Addr)
 make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
index b28b72842ed3af10ed1013d459f8284aa372bb49..c36548f4fcc09cd434e0e4677703b9d8e1ee4ea4 100644 (file)
@@ -39,6 +39,9 @@ struct link_map;
 
 extern ElfW(Addr) _dl_boot_fptr_table [];
 
+/* Must be called before any other function.  */
+extern void _dl_fptr_init (void);
+
 extern ElfW(Addr) _dl_make_fptr (struct link_map *, const ElfW(Sym) *,
                                 ElfW(Addr));