New "find" command.
[deliverable/binutils-gdb.git] / bfd / mach-o.c
index 666cf650999f673cb6f0c69929eddf6bd129a8eb..bde89b04034cc78110a70aa277b2c126f9e3c053 100644 (file)
@@ -1,12 +1,12 @@
 /* Mach-O support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "mach-o.h"
 #include "bfd.h"
-#include "sysdep.h"
 #include "libbfd.h"
 #include "libiberty.h"
 #include <ctype.h>
@@ -52,9 +53,6 @@
 #define bfd_mach_o_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_mach_o_read_minisymbols                   _bfd_generic_read_minisymbols
 #define bfd_mach_o_minisymbol_to_symbol               _bfd_generic_minisymbol_to_symbol
-#define bfd_mach_o_get_reloc_upper_bound              _bfd_norelocs_get_reloc_upper_bound
-#define bfd_mach_o_canonicalize_reloc                 _bfd_norelocs_canonicalize_reloc
-#define bfd_mach_o_bfd_reloc_type_lookup              _bfd_norelocs_bfd_reloc_type_lookup
 #define bfd_mach_o_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
 #define bfd_mach_o_bfd_relax_section                  bfd_generic_relax_section
 #define bfd_mach_o_bfd_link_hash_table_create         _bfd_generic_link_hash_table_create
@@ -568,7 +566,7 @@ bfd_mach_o_write_contents (bfd *abfd)
 
 static int
 bfd_mach_o_sizeof_headers (bfd *a ATTRIBUTE_UNUSED,
-                          bfd_boolean b ATTRIBUTE_UNUSED)
+                          struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   return 0;
 }
@@ -646,7 +644,7 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
   sprintf (sname, "%s.%s.%s", prefix, section->segname, section->sectname);
 
   flags = SEC_ALLOC;
-  if (!(section->flags & BFD_MACH_O_S_ZEROFILL))
+  if ((section->flags & SECTION_TYPE) != BFD_MACH_O_S_ZEROFILL)
     flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
   bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, flags);
   if (bfdsec == NULL)
@@ -1925,13 +1923,18 @@ bfd_mach_o_core_fetch_environment (bfd *abfd,
              if (size > (end - start))
                size = (end - start);
 
-             buf = bfd_realloc (buf, size);
-
+             buf = bfd_realloc_or_free (buf, size);
+             if (buf == NULL)
+               return -1;
+             
              bfd_seek (abfd, end - size, SEEK_SET);
              nread = bfd_bread (buf, size, abfd);
 
              if (nread != size)
-               return -1;
+               {
+                 free (buf);
+                 return -1;
+               }
 
              for (offset = 4; offset <= size; offset += 4)
                {
@@ -1954,6 +1957,7 @@ bfd_mach_o_core_fetch_environment (bfd *abfd,
                      *rlen = top - bottom;
 
                      memcpy (*rbuf, buf + size - *rlen, *rlen);
+                     free (buf);
                      return 0;
                    }
                }
@@ -1963,6 +1967,8 @@ bfd_mach_o_core_fetch_environment (bfd *abfd,
 
              size *= 2;
            }
+
+         free (buf);
        }
     }
 
This page took 0.025255 seconds and 4 git commands to generate.