From 2203f786c8976ce32d97fda1610b598b41c7d38e Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 9 May 1991 23:48:26 +0000 Subject: [PATCH] Add bfd_generic_get_section_contents. --- bfd/libbfd.c | 24 ++++++++++++++++++------ bfd/libbfd.h | 6 +++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/bfd/libbfd.c b/bfd/libbfd.c index f278a9cb63d..ec6a22365dc 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -325,10 +325,22 @@ _do_putllong (data, addr) addr[2] = (bfd_byte)(data >> 16); addr[3] = (bfd_byte)(data >> 24); } + +/* 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); +} diff --git a/bfd/libbfd.h b/bfd/libbfd.h index ad75ac2f0cd..19589c8ef55 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -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 -- 2.30.2