]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
solib-darwin: simplify code.
authorTristan Gingold <tristan.gingold@adacore.com>
Fri, 18 Apr 2014 09:03:46 +0000 (11:03 +0200)
committerTristan Gingold <tristan.gingold@adacore.com>
Fri, 18 Apr 2014 09:03:46 +0000 (11:03 +0200)
Use bfd_mach_o_get_base_address to extract load address.

gdb/
* solib-darwin.c (darwin_solib_create_inferior_hook): Simplify
code by using bfd_mach_o_get_base_address.

gdb/ChangeLog
gdb/solib-darwin.c

index b00cca9ba0aff9038fb79bc407f0d7eefc769cdd..c9b914ae54e908c9c7a50a7824fcb5a98102f0de 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-18  Tristan Gingold  <gingold@adacore.com>
+
+       * solib-darwin.c (darwin_solib_create_inferior_hook): Simplify
+       code by using bfd_mach_o_get_base_address.
+
 2014-04-17  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * spu-tdep.c: Include "dwarf2-frame.h" and "ax.h".
index a9989ea27dced038d4914c2bcf30d5701049d5f7..03b51d5b92c04226c6d52ad5bf44ee46bae49672 100644 (file)
@@ -524,26 +524,10 @@ darwin_solib_create_inferior_hook (int from_tty)
   load_addr = darwin_read_exec_load_addr (info);
   if (load_addr != 0 && symfile_objfile != NULL)
     {
-      CORE_ADDR vmaddr = 0;
-      struct mach_o_data_struct *md = bfd_mach_o_get_data (exec_bfd);
-      unsigned int i, num;
+      CORE_ADDR vmaddr;
 
       /* Find the base address of the executable.  */
-      for (i = 0; i < md->header.ncmds; i++)
-       {
-         struct bfd_mach_o_load_command *cmd = &md->commands[i];
-
-         if (cmd->type != BFD_MACH_O_LC_SEGMENT
-             && cmd->type != BFD_MACH_O_LC_SEGMENT_64)
-           continue;
-         if (cmd->command.segment.fileoff == 0
-             && cmd->command.segment.vmaddr != 0
-             && cmd->command.segment.filesize != 0)
-           {
-             vmaddr = cmd->command.segment.vmaddr;
-             break;
-           }
-       }
+      vmaddr = bfd_mach_o_get_base_address (exec_bfd);
 
       /* Relocate.  */
       if (vmaddr != load_addr)