Add bfd_generic_get_section_contents.
authorJohn Gilmore <gnu@cygnus>
Thu, 9 May 1991 23:48:26 +0000 (23:48 +0000)
committerJohn Gilmore <gnu@cygnus>
Thu, 9 May 1991 23:48:26 +0000 (23:48 +0000)
bfd/libbfd.c
bfd/libbfd.h

index f278a9c..ec6a223 100644 (file)
@@ -325,10 +325,22 @@ _do_putllong (data, addr)
        addr[2] = (bfd_byte)(data >> 16);
        addr[3] = (bfd_byte)(data >> 24);
 }
+\f
+/* Default implementation */
 
-
-
-
-
-
-
+boolean
+bfd_generic_get_section_contents (abfd, section, location, offset, count)
+     bfd *abfd;
+     sec_ptr section;
+     PTR location;
+     file_ptr offset;
+     int count;
+{
+    if (count == 0)
+       return true;
+    if (offset >= section->size
+       || bfd_seek(abfd, section->filepos + offset, SEEK_SET) == -1
+       || bfd_read(location, 1, count, abfd) != count)
+       return (false); /* on error */
+    return (true);
+}
index ad75ac2..19589c8 100644 (file)
@@ -125,10 +125,14 @@ PROTO (boolean, bsd_write_armap, (bfd *arch, unsigned int elength,
 PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength,
                                   struct orl *map, int orl_count, int stridx));
 
-PROTO ( bfd *,bfd_generic_openr_next_archived_file, (bfd *archive, bfd *last_file));
+PROTO (bfd *, bfd_generic_openr_next_archived_file, (bfd *archive,
+                                                    bfd *last_file));
 
 PROTO(int, bfd_generic_stat_arch_elt, (bfd *, struct stat *));
 
+PROTO(boolean, bfd_generic_get_section_contents,
+      (bfd *abfd, sec_ptr section, PTR location, file_ptr offset, int count));
+
 /* Macros to tell if bfds are read or write enabled.
 
    Note that bfds open for read may be scribbled into if the fd passed