X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fbfdio.c;h=792ccdab923a98328f08e41a588190136213502c;hb=5430098f1807e084fe4ff5057040d68435f3d8a2;hp=f8c9f3e4c418ad67762124902ffa73e3227bb05a;hpb=36f0a48f6c9a1927618d55b4a7df8ddfbfd0fb9d;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/bfdio.c b/bfd/bfdio.c index f8c9f3e4c4..792ccdab92 100644 --- a/bfd/bfdio.c +++ b/bfd/bfdio.c @@ -1,8 +1,6 @@ /* Low-level I/O routines for BFDs. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 - Free Software Foundation, Inc. + Copyright (C) 1990-2017 Free Software Foundation, Inc. Written by Cygnus Support. @@ -43,7 +41,7 @@ #endif file_ptr -real_ftell (FILE *file) +_bfd_real_ftell (FILE *file) { #if defined (HAVE_FTELLO64) return ftello64 (file); @@ -55,7 +53,7 @@ real_ftell (FILE *file) } int -real_fseek (FILE *file, file_ptr offset, int whence) +_bfd_real_fseek (FILE *file, file_ptr offset, int whence) { #if defined (HAVE_FSEEKO64) return fseeko64 (file, offset, whence); @@ -84,13 +82,12 @@ close_on_exec (FILE *file) } FILE * -real_fopen (const char *filename, const char *modes) +_bfd_real_fopen (const char *filename, const char *modes) { #ifdef VMS - char vms_modes[4]; char *vms_attr; - /* On VMS, fopen allows file attributes as optionnal arguments. + /* On VMS, fopen allows file attributes as optional arguments. We need to use them but we'd better to use the common prototype. In fopen-vms.h, they are separated from the mode with a comma. Split here. */ @@ -185,7 +182,8 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) this element. */ if (abfd->arelt_data != NULL) { - size_t maxbytes = arelt_size (abfd); + bfd_size_type maxbytes = arelt_size (abfd); + if (abfd->where + size > maxbytes) { if (abfd->where >= maxbytes) @@ -233,10 +231,15 @@ bfd_tell (bfd *abfd) if (abfd->iovec) { + bfd *parent_bfd = abfd; ptr = abfd->iovec->btell (abfd); - if (abfd->my_archive) - ptr -= abfd->origin; + while (parent_bfd->my_archive != NULL + && !bfd_is_thin_archive (parent_bfd->my_archive)) + { + ptr -= parent_bfd->origin; + parent_bfd = parent_bfd->my_archive; + } } else ptr = 0; @@ -287,7 +290,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) if (direction == SEEK_CUR && position == 0) return 0; - if (abfd->format != bfd_archive && abfd->my_archive == 0) + if (abfd->my_archive == NULL || bfd_is_thin_archive (abfd->my_archive)) { if (direction == SEEK_SET && (bfd_vma) position == abfd->where) return 0; @@ -308,8 +311,17 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) } file_position = position; - if (direction == SEEK_SET && abfd->my_archive != NULL) - file_position += abfd->origin; + if (direction == SEEK_SET) + { + bfd *parent_bfd = abfd; + + while (parent_bfd->my_archive != NULL + && !bfd_is_thin_archive (parent_bfd->my_archive)) + { + file_position += parent_bfd->origin; + parent_bfd = parent_bfd->my_archive; + } + } if (abfd->iovec) result = abfd->iovec->bseek (abfd, file_position, direction); @@ -574,7 +586,7 @@ memory_bclose (struct bfd *abfd) free (bim); abfd->iostream = NULL; - return TRUE; + return 0; } static int