* gdb.texinfo (Target Description Format): Add version attribute
[deliverable/binutils-gdb.git] / gdb / solib-svr4.c
index 2d3cae0f5ef4aa9a586dec336b6280c80d57a703..c531ccb1006f7ba95877a9e2708dc4026537fbd6 100644 (file)
@@ -239,12 +239,16 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_list *so)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
 
+  /* Assume that everything is a library if the dynamic loader was loaded
+     late by a static executable.  */
+  if (bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
+    return 0;
+
   return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
                                builtin_type_void_data_ptr) == 0;
 }
 
 static CORE_ADDR debug_base;   /* Base of dynamic linker structures */
-static CORE_ADDR breakpoint_addr;      /* Address where end bkpt is set */
 
 /* Validity flag for debug_loader_offset.  */
 static int debug_loader_offset_p;
@@ -387,7 +391,18 @@ elf_locate_base (void)
   /* Find the start address of the .dynamic section.  */
   dyninfo_sect = bfd_get_section_by_name (exec_bfd, ".dynamic");
   if (dyninfo_sect == NULL)
-    return 0;
+    {
+      /* This may be a static executable.  Look for the symbol
+        conventionally named _r_debug, as a last resort.  */
+      struct minimal_symbol *msymbol;
+
+      msymbol = lookup_minimal_symbol ("_r_debug", NULL, symfile_objfile);
+      if (msymbol != NULL)
+       return SYMBOL_VALUE_ADDRESS (msymbol);
+      else
+       return 0;
+    }
+
   dyninfo_addr = bfd_section_vma (exec_bfd, dyninfo_sect);
 
   /* Read in .dynamic section, silently ignore errors.  */
@@ -886,7 +901,7 @@ static CORE_ADDR interp_text_sect_high;
 static CORE_ADDR interp_plt_sect_low;
 static CORE_ADDR interp_plt_sect_high;
 
-static int
+int
 svr4_in_dynsym_resolve_code (CORE_ADDR pc)
 {
   return ((pc >= interp_text_sect_low && pc < interp_text_sect_high)
@@ -959,8 +974,6 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ)
 static int
 enable_break (void)
 {
-  int success = 0;
-
 #ifdef BKPT_AT_SYMBOL
 
   struct minimal_symbol *msymbol;
@@ -1113,11 +1126,10 @@ enable_break (void)
                "and track explicitly loaded dynamic code."));
     }
 
-  /* Scan through the list of symbols, trying to look up the symbol and
-     set a breakpoint there.  Terminate loop when we/if we succeed. */
+  /* Scan through the lists of symbols, trying to look up the symbol and
+     set a breakpoint there.  Terminate loop when we/if we succeed.  */
 
-  breakpoint_addr = 0;
-  for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
+  for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
     {
       msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
       if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
@@ -1127,12 +1139,18 @@ enable_break (void)
        }
     }
 
-  /* Nothing good happened.  */
-  success = 0;
-
+  for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
+    {
+      msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
+      if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
+       {
+         create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol));
+         return 1;
+       }
+    }
 #endif /* BKPT_AT_SYMBOL */
 
-  return (success);
+  return 0;
 }
 
 /*
@@ -1330,17 +1348,10 @@ svr4_solib_create_inferior_hook (void)
   svr4_relocate_main_executable ();
 
   if (!svr4_have_link_map_offsets ())
-    {
-      warning (_("no shared library support for this OS / ABI"));
-      return;
-
-    }
+    return;
 
   if (!enable_break ())
-    {
-      warning (_("shared library handler failed to enable breakpoint"));
-      return;
-    }
+    return;
 
 #if defined(_SCO_DS)
   /* SCO needs the loop below, other systems should be using the
@@ -1394,17 +1405,17 @@ svr4_free_so (struct so_list *so)
    natural pointer/address correspondence.  (For example, on the MIPS,
    converting a 32-bit pointer to a 64-bit CORE_ADDR requires you to
    sign-extend the value.  There, simply truncating the bits above
-   TARGET_PTR_BIT, as we do below, is no good.)  This should probably
+   gdbarch_ptr_bit, as we do below, is no good.)  This should probably
    be a new gdbarch method or something.  */
 static CORE_ADDR
 svr4_truncate_ptr (CORE_ADDR addr)
 {
-  if (TARGET_PTR_BIT == sizeof (CORE_ADDR) * 8)
+  if (gdbarch_ptr_bit (current_gdbarch) == sizeof (CORE_ADDR) * 8)
     /* We don't need to truncate anything, and the bit twiddling below
        will fail due to overflow problems.  */
     return addr;
   else
-    return addr & (((CORE_ADDR) 1 << TARGET_PTR_BIT) - 1);
+    return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (current_gdbarch)) - 1);
 }
 
 
@@ -1541,7 +1552,7 @@ svr4_lp64_fetch_link_map_offsets (void)
 }
 \f
 
-static struct target_so_ops svr4_so_ops;
+struct target_so_ops svr4_so_ops;
 
 extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */
 
This page took 0.02462 seconds and 4 git commands to generate.