summaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2011-04-11 04:08:07 +0000
committerAlan Modra <amodra@bigpond.net.au>2011-04-11 04:08:07 +0000
commit16beaaa62261c6bf0650e68a4f163c826b9fd79e (patch)
treec2750a4fd45b32481e87a2770789e87119c0e34b /bfd/libbfd.c
parent3e04863170d9d0863281e441b304398ccdc6292f (diff)
downloadbinutils-redhat-16beaaa62261c6bf0650e68a4f163c826b9fd79e.tar.gz
* bfd-in.h (bfd_get_section_limit): Don't use rawsize with output
sections. * libbfd.c (_bfd_generic_get_section_contents): Likewise. (_bfd_generic_get_section_contents_in_window): Likewise. * section.c (bfd_get_section_contents): Likewise. * compress.c (bfd_get_full_section_contents): Likewise. * elf32-rx.c (rx_final_link): Ignore rawsize. * elf32-microblaze.c (microblaze_elf_relocate_section): Use correct bfd with bfd_get_section_limit. * elfxx-ia64.c (elfNN_ia64_choose_gp): Add "final" parameter. Use os->size during final link. Update callers. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 8b24378456..4e5813aaf7 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -866,7 +866,15 @@ _bfd_generic_get_section_contents (bfd *abfd,
return FALSE;
}
- sz = section->rawsize ? section->rawsize : section->size;
+ /* We do allow reading of a section after bfd_final_link has
+ written the contents out to disk. In that situation, rawsize is
+ just a stale version of size, so ignore it. Otherwise we must be
+ reading an input section, where rawsize, if different to size,
+ is the on-disk size. */
+ if (abfd->direction != write_direction && section->rawsize != 0)
+ sz = section->rawsize;
+ else
+ sz = section->size;
if (offset + count < count
|| offset + count > sz)
{
@@ -919,7 +927,10 @@ _bfd_generic_get_section_contents_in_window
w->data = w->i->data;
return bfd_get_section_contents (abfd, section, w->data, offset, count);
}
- sz = section->rawsize ? section->rawsize : section->size;
+ if (abfd->direction != write_direction && section->rawsize != 0)
+ sz = section->rawsize;
+ else
+ sz = section->size;
if (offset + count > sz
|| ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
TRUE))