Fix disabling of solib probes when LD_AUDITing
authorGeorge Barrett <bob@bob131.so>
Sun, 15 Dec 2019 00:12:09 +0000 (11:12 +1100)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sat, 21 Dec 2019 21:02:19 +0000 (16:02 -0500)
The SVR4 solib event handler determines whether an event is related to a
non-base link namespace by comparing the event's debug struct address
to the debug struct address of the initial program image. However, this
can fail when using LD_AUDIT as audit libraries are loaded before the
loader has initialised the initial program image's debug struct. When
the event handler fails to find the debug struct, the probe-based
debugger interface is disabled and a warning is flagged to the user.

This commit adds a fallback test to help determine whether an event is
for a foreign link namespace when the debug struct isn't available.

gdb/ChangeLog:
2019-12-15  George Barrett  <bob@bob131.so>

* solib-svr4.c (svr4_handle_solib_event): Add fallback link
namespace test for when the debug struct isn't available.

gdb/ChangeLog
gdb/solib-svr4.c

index 0ba175a43153d7559b0ce6748f745fd5b68c9725..acf9106e844b0f49487d28d9b18ac8325548f5a2 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-21  George Barrett  <bob@bob131.so>
+
+       * solib-svr4.c (svr4_handle_solib_event): Add fallback link
+       namespace test for when the debug struct isn't available.
+
 2019-12-21  Eli Zaretskii  <eliz@gnu.org>
 
        * top.c (print_gdb_configuration): Print "--with-xxhash" or
index de765576d0b7fda28028b4899a79ccffb16f4fae..f0c7769ac2c95259e9eb87990eb4dbc78da8a970 100644 (file)
@@ -1942,7 +1942,27 @@ svr4_handle_solib_event (void)
     /* Always locate the debug struct, in case it moved.  */
     info->debug_base = 0;
     if (locate_base (info) == 0)
-      return;
+      {
+       /* It's possible for the reloc_complete probe to be triggered before
+          the linker has set the DT_DEBUG pointer (for example, when the
+          linker has finished relocating an LD_AUDIT library or its
+          dependencies).  Since we can't yet handle libraries from other link
+          namespaces, we don't lose anything by ignoring them here.  */
+       struct value *link_map_id_val;
+       try
+         {
+           link_map_id_val = pa->prob->evaluate_argument (0, frame);
+         }
+       catch (const gdb_exception_error)
+         {
+           link_map_id_val = NULL;
+         }
+       /* glibc and illumos' libc both define LM_ID_BASE as zero.  */
+       if (link_map_id_val != NULL && value_as_long (link_map_id_val) != 0)
+         action = DO_NOTHING;
+       else
+         return;
+      }
 
     /* GDB does not currently support libraries loaded via dlmopen
        into namespaces other than the initial one.  We must ignore
This page took 0.032129 seconds and 4 git commands to generate.