]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/dl-reloc-static-pie.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / elf / dl-reloc-static-pie.c
index bd2d516e5d75ae76cd8832b7946b178e15f0e328..95aee984e802ddf5e0b0741071829daafa229a52 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for relocating static PIE.
-   Copyright (C) 2017-2018 Free Software Foundation, Inc.
+   Copyright (C) 2017-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
@@ -48,5 +48,21 @@ _dl_relocate_static_pie (void)
      data access using the global offset table.  */
   ELF_DYNAMIC_RELOCATE (main_map, 0, 0, 0);
   main_map->l_relocated = 1;
+
+  /* Initialize _r_debug.  */
+  struct r_debug *r = _dl_debug_initialize (0, LM_ID_BASE);
+  r->r_state = RT_CONSISTENT;
+
+  /* Set up debugging before the debugger is notified for the first
+     time.  */
+# ifdef ELF_MACHINE_DEBUG_SETUP
+  /* Some machines (e.g. MIPS) don't use DT_DEBUG in this way.  */
+  ELF_MACHINE_DEBUG_SETUP (main_map, r);
+# else
+  if (main_map->l_info[DT_DEBUG] != NULL)
+    /* There is a DT_DEBUG entry in the dynamic section.  Fill it in
+       with the run-time address of the r_debug structure  */
+    main_map->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
+# endif
 }
 #endif