/* 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>
#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
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;
}
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)
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)
{
*rlen = top - bottom;
memcpy (*rbuf, buf + size - *rlen, *rlen);
+ free (buf);
return 0;
}
}
size *= 2;
}
+
+ free (buf);
}
}