From f977e865cbf5fad99f476ab9d2d8068db943ac33 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sat, 26 Mar 1994 20:25:48 +0000 Subject: [PATCH] * som.c (som_get_section_contents): New function. Do not try to actually read data from a section that doesn't have either SEC_LOAD or SEC_DEBUGGING set (eg $BSS$) just return true. --- bfd/ChangeLog | 4 ++++ bfd/som.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1896682fba1..1a404f8ade5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,9 @@ Sat Mar 26 10:25:43 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + * som.c (som_get_section_contents): New function. Do not try + to actually read data from a section that doesn't have either + SEC_LOAD or SEC_DEBUGGING set (eg $BSS$) just return true. + * libbfd.c (bfd_read): Set bfd_error as appropriate for a short read. (bfd_error_system_call or bfd_error_file_truncated). diff --git a/bfd/som.c b/bfd/som.c index 62812f5e3fc..6fa3f8bc666 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -158,6 +158,8 @@ static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); static boolean som_bfd_is_local_label PARAMS ((bfd *, asymbol *)); static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); +static boolean som_get_section_contents PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigned long)); static boolean som_find_nearest_line PARAMS ((bfd *, asection *, @@ -4441,6 +4443,23 @@ bfd_som_attach_aux_hdr (abfd, type, string) return true; } +static boolean +som_get_section_contents (abfd, section, location, offset, count) + bfd *abfd; + sec_ptr section; + PTR location; + file_ptr offset; + bfd_size_type count; +{ + if (count == 0 || ((section->flags & (SEC_LOAD | SEC_DEBUGGING)) == 0)) + return true; + if ((bfd_size_type)(offset+count) > section->_raw_size + || bfd_seek (abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1 + || bfd_read (location, (bfd_size_type)1, count, abfd) != count) + return (false); /* on error */ + return (true); +} + static boolean som_set_section_contents (abfd, section, location, offset, count) bfd *abfd; @@ -5427,7 +5446,6 @@ som_write_armap (abfd) #define som_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr #define som_close_and_cleanup bfd_generic_close_and_cleanup -#define som_get_section_contents bfd_generic_get_section_contents #define som_bfd_get_relocated_section_contents \ bfd_generic_get_relocated_section_contents -- 2.30.2