2004-02-11 Andrew Cagney <cagney@redhat.com>
* bfd-in.h: Update copyright. (bfd_tell): Change return type to file_ptr. * bfd-in2.h: Re-generate. * cache.c: Update copyright. (bfd_cache_lookup_worker): Use real_fseek, do not cast offset parameter. (close_one): Use real_ftell. * bfdio.c: Update copyright. (real_ftell, real_fseek): New functions. (bfd_tell): Use real_fseek and real_ftell, change return type to file_ptr. (bfd_seek): Use real_ftell and real_fseek, change type of file_position to a file_ptr. * libbfd-in.h: Update copyright. (real_ftell, real_fseek): Declare. * libbfd.h: Re-generate.
This commit is contained in:
parent
63338fd920
commit
7c1927339f
7 changed files with 78 additions and 21 deletions
|
@ -1,5 +1,22 @@
|
||||||
2004-02-11 Andrew Cagney <cagney@redhat.com>
|
2004-02-11 Andrew Cagney <cagney@redhat.com>
|
||||||
|
|
||||||
|
* bfd-in.h: Update copyright.
|
||||||
|
(bfd_tell): Change return type to file_ptr.
|
||||||
|
* bfd-in2.h: Re-generate.
|
||||||
|
* cache.c: Update copyright.
|
||||||
|
(bfd_cache_lookup_worker): Use real_fseek, do not cast offset
|
||||||
|
parameter.
|
||||||
|
(close_one): Use real_ftell.
|
||||||
|
* bfdio.c: Update copyright.
|
||||||
|
(real_ftell, real_fseek): New functions.
|
||||||
|
(bfd_tell): Use real_fseek and real_ftell, change return type to
|
||||||
|
file_ptr.
|
||||||
|
(bfd_seek): Use real_ftell and real_fseek, change type of
|
||||||
|
file_position to a file_ptr.
|
||||||
|
* libbfd-in.h: Update copyright.
|
||||||
|
(real_ftell, real_fseek): Declare.
|
||||||
|
* libbfd.h: Re-generate.
|
||||||
|
|
||||||
* configure.in (AC_CHECK_FUNCS): Check for ftello, ftello64,
|
* configure.in (AC_CHECK_FUNCS): Check for ftello, ftello64,
|
||||||
fseeko and fseeko64. Determine bfd_file_ptr.
|
fseeko and fseeko64. Determine bfd_file_ptr.
|
||||||
* configure: Re-generate.
|
* configure: Re-generate.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Main header file for the bfd library -- portable access to object files.
|
/* Main header file for the bfd library -- portable access to object files.
|
||||||
|
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Contributed by Cygnus Support.
|
Contributed by Cygnus Support.
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ extern void bfd_hash_traverse
|
||||||
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
|
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
|
||||||
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
||||||
extern int bfd_seek (bfd *, file_ptr, int);
|
extern int bfd_seek (bfd *, file_ptr, int);
|
||||||
extern ufile_ptr bfd_tell (bfd *);
|
extern file_ptr bfd_tell (bfd *);
|
||||||
extern int bfd_flush (bfd *);
|
extern int bfd_flush (bfd *);
|
||||||
extern int bfd_stat (bfd *, struct stat *);
|
extern int bfd_stat (bfd *, struct stat *);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/* Main header file for the bfd library -- portable access to object files.
|
/* Main header file for the bfd library -- portable access to object files.
|
||||||
|
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Contributed by Cygnus Support.
|
Contributed by Cygnus Support.
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ extern void bfd_hash_traverse
|
||||||
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
|
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
|
||||||
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
|
||||||
extern int bfd_seek (bfd *, file_ptr, int);
|
extern int bfd_seek (bfd *, file_ptr, int);
|
||||||
extern ufile_ptr bfd_tell (bfd *);
|
extern file_ptr bfd_tell (bfd *);
|
||||||
extern int bfd_flush (bfd *);
|
extern int bfd_flush (bfd *);
|
||||||
extern int bfd_stat (bfd *, struct stat *);
|
extern int bfd_stat (bfd *, struct stat *);
|
||||||
|
|
||||||
|
|
40
bfd/bfdio.c
40
bfd/bfdio.c
|
@ -1,6 +1,8 @@
|
||||||
/* Low-level I/O routines for BFDs.
|
/* Low-level I/O routines for BFDs.
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|
||||||
2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
|
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by Cygnus Support.
|
Written by Cygnus Support.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
@ -36,6 +38,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
#define S_IXOTH 0001 /* Execute by others. */
|
#define S_IXOTH 0001 /* Execute by others. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
file_ptr
|
||||||
|
real_ftell (FILE *file)
|
||||||
|
{
|
||||||
|
#if defined (HAVE_FTELLO64)
|
||||||
|
return ftello64 (file);
|
||||||
|
#elif defined (HAVE_FTELLO)
|
||||||
|
return ftello (file);
|
||||||
|
#else
|
||||||
|
return ftell (file);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
real_fseek (FILE *file, file_ptr offset, int whence)
|
||||||
|
{
|
||||||
|
#if defined (HAVE_FSEEKO64)
|
||||||
|
return fseeko64 (file, offset, whence);
|
||||||
|
#elif defined (HAVE_FSEEKO)
|
||||||
|
return fseeko (file, offset, whence);
|
||||||
|
#else
|
||||||
|
return fseek (file, offset, whence);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Note that archive entries don't have streams; they share their parent's.
|
/* Note that archive entries don't have streams; they share their parent's.
|
||||||
This allows someone to play with the iostream behind BFD's back.
|
This allows someone to play with the iostream behind BFD's back.
|
||||||
|
|
||||||
|
@ -162,7 +188,7 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
|
||||||
return nwrote;
|
return nwrote;
|
||||||
}
|
}
|
||||||
|
|
||||||
bfd_vma
|
file_ptr
|
||||||
bfd_tell (bfd *abfd)
|
bfd_tell (bfd *abfd)
|
||||||
{
|
{
|
||||||
file_ptr ptr;
|
file_ptr ptr;
|
||||||
|
@ -170,7 +196,7 @@ bfd_tell (bfd *abfd)
|
||||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||||
return abfd->where;
|
return abfd->where;
|
||||||
|
|
||||||
ptr = ftell (bfd_cache_lookup (abfd));
|
ptr = real_ftell (bfd_cache_lookup (abfd));
|
||||||
|
|
||||||
if (abfd->my_archive)
|
if (abfd->my_archive)
|
||||||
ptr -= abfd->origin;
|
ptr -= abfd->origin;
|
||||||
|
@ -217,7 +243,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
long file_position;
|
file_ptr file_position;
|
||||||
/* For the time being, a BFD may not seek to it's end. The problem
|
/* For the time being, a BFD may not seek to it's end. The problem
|
||||||
is that we don't easily have a way to recognize the end of an
|
is that we don't easily have a way to recognize the end of an
|
||||||
element in an archive. */
|
element in an archive. */
|
||||||
|
@ -278,7 +304,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
|
||||||
tripping the abort, we can probably safely disable this code,
|
tripping the abort, we can probably safely disable this code,
|
||||||
so that the real optimizations happen. */
|
so that the real optimizations happen. */
|
||||||
file_ptr where_am_i_now;
|
file_ptr where_am_i_now;
|
||||||
where_am_i_now = ftell (bfd_cache_lookup (abfd));
|
where_am_i_now = real_ftell (bfd_cache_lookup (abfd));
|
||||||
if (abfd->my_archive)
|
if (abfd->my_archive)
|
||||||
where_am_i_now -= abfd->origin;
|
where_am_i_now -= abfd->origin;
|
||||||
if (where_am_i_now != abfd->where)
|
if (where_am_i_now != abfd->where)
|
||||||
|
@ -307,7 +333,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
|
||||||
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
||||||
file_position += abfd->origin;
|
file_position += abfd->origin;
|
||||||
|
|
||||||
result = fseek (f, file_position, direction);
|
result = real_fseek (f, file_position, direction);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
int hold_errno = errno;
|
int hold_errno = errno;
|
||||||
|
|
10
bfd/cache.c
10
bfd/cache.c
|
@ -1,6 +1,8 @@
|
||||||
/* BFD library -- caching of file descriptors.
|
/* BFD library -- caching of file descriptors.
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, 2003
|
|
||||||
Free Software Foundation, Inc.
|
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
|
||||||
|
2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
@ -155,7 +157,7 @@ close_one (void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
kill->where = ftell ((FILE *) kill->iostream);
|
kill->where = real_ftell ((FILE *) kill->iostream);
|
||||||
|
|
||||||
return bfd_cache_delete (kill);
|
return bfd_cache_delete (kill);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +358,7 @@ bfd_cache_lookup_worker (bfd *abfd)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (abfd->where != (unsigned long) abfd->where)
|
if (abfd->where != (unsigned long) abfd->where)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (fseek ((FILE *) abfd->iostream, (long) abfd->where, SEEK_SET) != 0)
|
if (real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
/* libbfd.h -- Declarations used by bfd library *implementation*.
|
/* libbfd.h -- Declarations used by bfd library *implementation*.
|
||||||
(This include file is not for users of the library.)
|
(This include file is not for users of the library.)
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|
||||||
2000, 2001, 2002, 2003
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by Cygnus Support.
|
Written by Cygnus Support.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
@ -594,6 +595,11 @@ extern void _bfd_abort
|
||||||
#undef abort
|
#undef abort
|
||||||
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/* Manipulate a system FILE but using BFD's "file_ptr", rather than
|
||||||
|
the system "off_t" or "off64_t", as the offset. */
|
||||||
|
extern file_ptr real_ftell (FILE *file);
|
||||||
|
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
||||||
|
|
||||||
FILE * bfd_cache_lookup_worker
|
FILE * bfd_cache_lookup_worker
|
||||||
(bfd *);
|
(bfd *);
|
||||||
|
|
||||||
|
|
12
bfd/libbfd.h
12
bfd/libbfd.h
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
/* libbfd.h -- Declarations used by bfd library *implementation*.
|
/* libbfd.h -- Declarations used by bfd library *implementation*.
|
||||||
(This include file is not for users of the library.)
|
(This include file is not for users of the library.)
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|
||||||
2000, 2001, 2002, 2003
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
Free Software Foundation, Inc.
|
1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by Cygnus Support.
|
Written by Cygnus Support.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
@ -599,6 +600,11 @@ extern void _bfd_abort
|
||||||
#undef abort
|
#undef abort
|
||||||
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/* Manipulate a system FILE but using BFD's "file_ptr", rather than
|
||||||
|
the system "off_t" or "off64_t", as the offset. */
|
||||||
|
extern file_ptr real_ftell (FILE *file);
|
||||||
|
extern int real_fseek (FILE *file, file_ptr offset, int whence);
|
||||||
|
|
||||||
FILE * bfd_cache_lookup_worker
|
FILE * bfd_cache_lookup_worker
|
||||||
(bfd *);
|
(bfd *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue