Add bfd_generic_get_section_contents.

This commit is contained in:
John Gilmore
1991-05-09 23:48:26 +00:00
parent 7564d3d74a
commit 2203f786c8
2 changed files with 23 additions and 7 deletions

View File

@ -325,10 +325,22 @@ _do_putllong (data, addr)
addr[2] = (bfd_byte)(data >> 16); addr[2] = (bfd_byte)(data >> 16);
addr[3] = (bfd_byte)(data >> 24); 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);
}

View 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, PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength,
struct orl *map, int orl_count, int stridx)); 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(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. /* Macros to tell if bfds are read or write enabled.
Note that bfds open for read may be scribbled into if the fd passed Note that bfds open for read may be scribbled into if the fd passed