This commit was generated by cvs2svn to track changes on a CVS vendor
[binutils-gdb.git] / bfd / bfd.c
index 3fa0e081c863e1de851b6489eba3a317fbc8f08c..5a23c5d690f406cbd8245cf3345273ff2b83bd18 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,5 +1,5 @@
 /* Generic BFD library interface and support routines.
 /* Generic BFD library interface and support routines.
-   Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
+   Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -44,8 +44,10 @@ CODE_FRAGMENT
 .       includes `<<bfd.h>>', IOSTREAM has been declared as a "char
 .       *", and MTIME as a "long".  Their correct types, to which they
 .       are cast when used, are "FILE *" and "time_t".    The iostream
 .       includes `<<bfd.h>>', IOSTREAM has been declared as a "char
 .       *", and MTIME as a "long".  Their correct types, to which they
 .       are cast when used, are "FILE *" and "time_t".    The iostream
-.       is the result of an fopen on the filename. *}
-.    char *iostream;
+.       is the result of an fopen on the filename.  However, if the
+.       BFD_IN_MEMORY flag is set, then iostream is actually a pointer
+.       to a bfd_in_memory struct.  *}
+.    PTR iostream;
 .
 .    {* Is the file descriptor being cached?  That is, can it be closed as
 .       needed, and re-opened when accessed later?  *}
 .
 .    {* Is the file descriptor being cached?  That is, can it be closed as
 .       needed, and re-opened when accessed later?  *}
@@ -158,6 +160,7 @@ CODE_FRAGMENT
 .      struct ieee_data_struct *ieee_data;
 .      struct ieee_ar_data_struct *ieee_ar_data;
 .      struct srec_data_struct *srec_data;
 .      struct ieee_data_struct *ieee_data;
 .      struct ieee_ar_data_struct *ieee_ar_data;
 .      struct srec_data_struct *srec_data;
+.      struct ihex_data_struct *ihex_data;
 .      struct tekhex_data_struct *tekhex_data;
 .      struct elf_obj_tdata *elf_obj_data;
 .      struct nlm_obj_tdata *nlm_obj_data;
 .      struct tekhex_data_struct *tekhex_data;
 .      struct elf_obj_tdata *elf_obj_data;
 .      struct nlm_obj_tdata *nlm_obj_data;
@@ -172,6 +175,7 @@ CODE_FRAGMENT
 .      struct osf_core_struct *osf_core_data;
 .      struct cisco_core_struct *cisco_core_data;
 .      struct versados_data_struct *versados_data;
 .      struct osf_core_struct *osf_core_data;
 .      struct cisco_core_struct *cisco_core_data;
 .      struct versados_data_struct *versados_data;
+.      struct netbsd_core_struct *netbsd_core_data;
 .      PTR any;
 .      } tdata;
 .  
 .      PTR any;
 .      } tdata;
 .  
@@ -747,6 +751,9 @@ bfd_get_size (abfd)
   FILE *fp;
   struct stat buf;
 
   FILE *fp;
   struct stat buf;
 
+  if ((abfd->flags & BFD_IN_MEMORY) != 0)
+    return ((struct bfd_in_memory *) abfd->iostream)->size;
+
   fp = bfd_cache_lookup (abfd);
   if (0 != fstat (fileno (fp), &buf))
     return 0;
   fp = bfd_cache_lookup (abfd);
   if (0 != fstat (fileno (fp), &buf))
     return 0;
@@ -808,6 +815,39 @@ bfd_set_gp_size (abfd, i)
     elf_gp_size (abfd) = i;
 }
 
     elf_gp_size (abfd) = i;
 }
 
+/* Get the GP value.  This is an internal function used by some of the
+   relocation special_function routines on targets which support a GP
+   register.  */
+
+bfd_vma
+_bfd_get_gp_value (abfd)
+     bfd *abfd;
+{
+  if (abfd->format == bfd_object)
+    {
+      if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+       return ecoff_data (abfd)->gp;
+      else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+       return elf_gp (abfd);
+    }
+  return 0;
+}
+
+/* Set the GP value.  */
+
+void
+_bfd_set_gp_value (abfd, v)
+     bfd *abfd;
+     bfd_vma v;
+{
+  if (abfd->format != bfd_object)
+    return;
+  if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+    ecoff_data (abfd)->gp = v;
+  else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+    elf_gp (abfd) = v;
+}
+
 /*
 FUNCTION
        bfd_scan_vma
 /*
 FUNCTION
        bfd_scan_vma