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 f278a9cb63d81d516a1e92107b8f1be259d573e1..ec6a22365dc1a094f1f41ea4a809ee1d36fbd1e0 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 ad75ac2f0cd9b2da2ce0ad3940cdcd7570da8ad2..19589c8ef551870af21f15f38c9a2c3215e59aec 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