]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/setup-vdso.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / elf / setup-vdso.h
index 1b969a071832328bbe534b6aaa1a4d1dcc3938ef..62785b98db92b4a60486c74186fb315495d4e7b4 100644 (file)
@@ -1,5 +1,5 @@
 /* Set up the data structures for the system-supplied DSO.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 static inline void __attribute__ ((always_inline))
 setup_vdso (struct link_map *main_map __attribute__ ((unused)),
            struct link_map ***first_preload __attribute__ ((unused)))
 {
-#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+#ifdef NEED_DL_SYSINFO_DSO
   if (GLRO(dl_sysinfo_dso) == NULL)
     return;
 
@@ -31,7 +31,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
      mapped and relocated it normally.  */
   struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL,
                                       0, LM_ID_BASE);
-  if (__builtin_expect (l != NULL, 1))
+  if (__glibc_likely (l != NULL))
     {
       static ElfW(Dyn) dyn_temp[DL_RO_DYN_TEMP_CNT] attribute_relro;
 
@@ -89,7 +89,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
             addresses in the vsyscall DSO pages in writev() calls.  */
          const char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB])
                                 + l->l_info[DT_SONAME]->d_un.d_val);
-         size_t len = strlen (dsoname);
+         size_t len = strlen (dsoname) + 1;
          char *copy = malloc (len);
          if (copy == NULL)
            _dl_fatal_printf ("out of memory\n");
@@ -99,13 +99,15 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
       /* Add the vDSO to the object list.  */
       _dl_add_to_namespace_list (l, LM_ID_BASE);
 
-# ifdef IS_IN_rtld
+# if IS_IN (rtld)
       /* Rearrange the list so this DSO appears after rtld_map.  */
       assert (l->l_next == NULL);
       assert (l->l_prev == main_map);
       GL(dl_rtld_map).l_next = l;
       l->l_prev = &GL(dl_rtld_map);
       *first_preload = &l->l_next;
+# else
+      GL(dl_nns) = 1;
 # endif
 
       /* We have a prelinked DSO preloaded by the system.  */