sys/types.h cleanup
[deliverable/binutils-gdb.git] / gdb / exec.c
index c61d5307521d75e08c5e5d9243aefd1f78abfbd9..afd32245de09404174906a366b16307ed99751a8 100644 (file)
@@ -37,7 +37,7 @@
 
 #include <fcntl.h>
 #include "readline/readline.h"
-#include "gdb_string.h"
+#include <string.h>
 
 #include "gdbcore.h"
 
@@ -187,8 +187,7 @@ exec_file_attach (char *filename, int from_tty)
       struct target_section *sections = NULL, *sections_end = NULL;
       char **matching;
 
-      scratch_chan = openp (getenv ("PATH"),
-                           OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
+      scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
                   write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
                            &scratch_pathname);
 #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
@@ -197,9 +196,7 @@ exec_file_attach (char *filename, int from_tty)
          char *exename = alloca (strlen (filename) + 5);
 
          strcat (strcpy (exename, filename), ".exe");
-         scratch_chan = openp (getenv ("PATH"),
-                               OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH,
-                               exename,
+         scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
             write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
             &scratch_pathname);
        }
@@ -227,7 +224,7 @@ exec_file_attach (char *filename, int from_tty)
        }
 
       gdb_assert (exec_filename == NULL);
-      exec_filename = xstrdup (scratch_pathname);
+      exec_filename = gdb_realpath_keepfile (scratch_pathname);
 
       if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
        {
@@ -441,6 +438,51 @@ add_target_sections (void *owner,
     }
 }
 
+/* Add the sections of OBJFILE to the current set of target sections.  */
+
+void
+add_target_sections_of_objfile (struct objfile *objfile)
+{
+  struct target_section_table *table = current_target_sections;
+  struct obj_section *osect;
+  int space;
+  unsigned count = 0;
+  struct target_section *ts;
+
+  if (objfile == NULL)
+    return;
+
+  /* Compute the number of sections to add.  */
+  ALL_OBJFILE_OSECTIONS (objfile, osect)
+    {
+      if (bfd_get_section_size (osect->the_bfd_section) == 0)
+       continue;
+      count++;
+    }
+
+  if (count == 0)
+    return;
+
+  space = resize_section_table (table, count);
+
+  ts = table->sections + space;
+
+  ALL_OBJFILE_OSECTIONS (objfile, osect)
+    {
+      if (bfd_get_section_size (osect->the_bfd_section) == 0)
+       continue;
+
+      gdb_assert (ts < table->sections + space + count);
+
+      ts->addr = obj_section_addr (osect);
+      ts->endaddr = obj_section_endaddr (osect);
+      ts->the_bfd_section = osect->the_bfd_section;
+      ts->owner = (void *) objfile;
+
+      ts++;
+    }
+}
+
 /* Remove all target sections owned by OWNER.
    OWNER must be the same value passed to add_target_sections.  */
 
This page took 0.02439 seconds and 4 git commands to generate.