* elf-hppa.h (elf_hppa_reloc_final_type): Handle R_PARISC_GPREL64,
[deliverable/binutils-gdb.git] / bfd / libbfd.c
index 3b27e08a8f3ac0f01bb885255619590a9b1ab1db..a225397c3e780fd18b39c940d19f78edd3fad542 100644 (file)
@@ -1,6 +1,6 @@
 /* Assorted BFD support routines, only used internally.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -8,7 +8,7 @@
 
    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 "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
 #ifndef HAVE_GETPAGESIZE
@@ -103,6 +104,23 @@ bfd_void (bfd *ignore ATTRIBUTE_UNUSED)
 {
 }
 
+long
+_bfd_norelocs_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
+                                    asection *sec ATTRIBUTE_UNUSED)
+{
+  return sizeof (arelent *);
+}
+
+long
+_bfd_norelocs_canonicalize_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+                                 asection *sec ATTRIBUTE_UNUSED,
+                                 arelent **relptr,
+                                 asymbol **symbols ATTRIBUTE_UNUSED)
+{
+  *relptr = NULL;
+  return 0;
+}
+
 bfd_boolean
 _bfd_nocore_core_file_matches_executable_p
   (bfd *ignore_core_bfd ATTRIBUTE_UNUSED,
@@ -247,6 +265,34 @@ bfd_realloc2 (void *ptr, bfd_size_type nmemb, bfd_size_type size)
   return ret;
 }
 
+/* Reallocate memory using realloc.
+   If this fails the pointer is freed before returning.  */
+
+void *
+bfd_realloc_or_free (void *ptr, bfd_size_type size)
+{
+  size_t amount = (size_t) size;
+  void *ret;
+
+  if (size != amount)
+    ret = NULL;
+  else if (ptr == NULL)
+    ret = malloc (amount);
+  else
+    ret = realloc (ptr, amount);
+
+  if (ret == NULL)
+    {
+      if (amount > 0)
+       bfd_set_error (bfd_error_no_memory);
+
+      if (ptr != NULL)
+       free (ptr);
+    }
+
+  return ret;
+}
+
 /* Allocate memory using malloc and clear it.  */
 
 void *
@@ -802,7 +848,8 @@ _bfd_generic_get_section_contents (bfd *abfd,
     return TRUE;
 
   sz = section->rawsize ? section->rawsize : section->size;
-  if (offset + count > sz)
+  if (offset + count < count
+      || offset + count > sz)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -1035,10 +1082,11 @@ _bfd_generic_find_line (bfd *abfd ATTRIBUTE_UNUSED,
 }
 
 bfd_boolean
-_bfd_generic_match_sections_by_type (bfd *abfd ATTRIBUTE_UNUSED,
-                                    const asection *asec ATTRIBUTE_UNUSED,
-                                    bfd *bbfd ATTRIBUTE_UNUSED,
-                                    const asection *bsec ATTRIBUTE_UNUSED)
+_bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED,
+                                       asection *isec ATTRIBUTE_UNUSED,
+                                       bfd *obfd ATTRIBUTE_UNUSED,
+                                       asection *osec ATTRIBUTE_UNUSED,
+                                       struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
 {
   return TRUE;
 }
This page took 0.029267 seconds and 4 git commands to generate.