(m32r_handle_align): Declare type of fragp.
[deliverable/binutils-gdb.git] / gdb / solib.c
index 5c982e2a90dd78b172d52e5e541f69183a28c7e8..5f9743f909ce57e90b061f02af8999177f9d49b8 100644 (file)
@@ -85,13 +85,13 @@ static char *solib_search_path = NULL;
 
    Search order:
    * If path is absolute, look in SOLIB_ABSOLUTE_PREFIX.
-   * If path is absolute, look for it literally (unmodified).
+   * If path is absolute or relative, look for it literally (unmodified).
    * Look in SOLIB_SEARCH_PATH.
    * Look in inferior's $PATH.
    * Look in inferior's $LD_LIBRARY_PATH.
 
    RETURNS
-   
+
    file handle for opened solib, or -1 for failure.  */
 
 int
@@ -100,20 +100,25 @@ solib_open (char *in_pathname, char **found_pathname)
   int found_file = -1;
   char *temp_pathname = NULL;
 
-  if (solib_absolute_prefix != NULL &&
-      ROOTED_P (in_pathname))
+  if (strchr (in_pathname, SLASH_CHAR))
     {
-      int  prefix_len = strlen (solib_absolute_prefix);
-
-      /* Remove trailing slashes from absolute prefix.  */
-      while (prefix_len > 0 && SLASH_P (solib_absolute_prefix[prefix_len - 1]))
-       prefix_len--;
-
-      /* Cat the prefixed pathname together.  */
-      temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1);
-      strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
-      temp_pathname[prefix_len] = '\0';
-      strcat (temp_pathname, in_pathname);
+      if (! ROOTED_P (in_pathname) || solib_absolute_prefix == NULL)
+        temp_pathname = in_pathname;
+      else
+       {
+         int prefix_len = strlen (solib_absolute_prefix);
+
+         /* Remove trailing slashes from absolute prefix.  */
+         while (prefix_len > 0
+                && SLASH_P (solib_absolute_prefix[prefix_len - 1]))
+           prefix_len--;
+
+         /* Cat the prefixed pathname together.  */
+         temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1);
+         strncpy (temp_pathname, solib_absolute_prefix, prefix_len);
+         temp_pathname[prefix_len] = '\0';
+         strcat (temp_pathname, in_pathname);
+       }
 
       /* Now see if we can open it.  */
       found_file = open (temp_pathname, O_RDONLY, 0);
@@ -137,7 +142,7 @@ solib_open (char *in_pathname, char **found_pathname)
 
   /* Done.  If not found, tough luck.  Return found_file and 
      (optionally) found_pathname.  */
-  if (found_pathname != NULL)
+  if (found_pathname != NULL && temp_pathname != NULL)
     *found_pathname = strsave (temp_pathname);
   return found_file;
 }
@@ -183,7 +188,7 @@ solib_map_sections (PTR arg)
 
   filename = tilde_expand (so->so_name);
 
-  old_chain = make_cleanup (free, filename);
+  old_chain = make_cleanup (xfree, filename);
   scratch_chan = solib_open (filename, &scratch_pathname);
 
   if (scratch_chan < 0)
@@ -266,7 +271,7 @@ free_so (struct so_list *so)
   char *bfd_filename = 0;
 
   if (so->sections)
-    free (so->sections);
+    xfree (so->sections);
       
   if (so->abfd)
     {
@@ -277,11 +282,11 @@ free_so (struct so_list *so)
     }
 
   if (bfd_filename)
-    free (bfd_filename);
+    xfree (bfd_filename);
 
   TARGET_SO_FREE_SO (so);
 
-  free (so);
+  xfree (so);
 }
 
 
@@ -609,6 +614,11 @@ info_sharedlibrary_command (char *ignore, int from_tty)
       addr_width = 16 + 4;
       addr_fmt = "016l";
     }
+  else
+    {
+      internal_error ("%s:%d: bfd_get_arch_size() returned unknown size %d",
+                     __FILE__, __LINE__, arch_size);
+    }
 
   update_solib_list (from_tty, 0);
 
This page took 0.024206 seconds and 4 git commands to generate.