From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6564 invoked by alias); 3 Nov 2005 16:09:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 6505 invoked by uid 22791); 3 Nov 2005 16:09:08 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 03 Nov 2005 16:09:07 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1EXheC-0000FA-Ou; Thu, 03 Nov 2005 11:09:04 -0500 Date: Thu, 03 Nov 2005 18:59:00 -0000 From: Daniel Jacobowitz To: binutils@sourceware.org Cc: gdb-patches@sourceware.org Subject: Support for opening large core files Message-ID: <20051103160904.GA855@nevyn.them.org> Mail-Followup-To: binutils@sourceware.org, gdb-patches@sourceware.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i X-SW-Source: 2005-11/txt/msg00059.txt.bz2 Hi Alan, This is the other change I mentioned to you on the gdb list a couple of weeks ago. If we don't do this, then when we try to reopen a very large file on a 32-bit system, fopen will fail. It works initially because gdb passes a file descriptor to bfd_fopen. Tested on i686-pc-linux-gnu, where it fixes bigcore.exp in the GDB testsuite. No regressions for binutils, though all the weakref gas tests fail. Checked in. Joel, is the 6.4 branch open? -- Daniel Jacobowitz CodeSourcery, LLC 2005-11-03 Daniel Jacobowitz * configure.in: Check for fopen64. * libbfd-in.h (real_fopen): New prototype. * configure, config.in, libbfd.h: Regenerated. * bfdio.c (real_fopen): New function. * opncls.c (bfd_fopen, bfd_fill_in_gnu_debuglink_section): Use it. * cache.c (bfd_open_file): Likewise. Index: bfdio.c =================================================================== RCS file: /cvs/src/src/bfd/bfdio.c,v retrieving revision 1.11 diff -u -p -r1.11 bfdio.c --- bfdio.c 4 May 2005 15:53:01 -0000 1.11 +++ bfdio.c 3 Nov 2005 15:47:23 -0000 @@ -63,6 +63,16 @@ real_fseek (FILE *file, file_ptr offset, #endif } +FILE * +real_fopen (const char *filename, const char *modes) +{ +#if defined (HAVE_FOPEN64) + return fopen64 (filename, modes); +#else + return fopen (filename, modes); +#endif +} + /* INTERNAL_DEFINITION struct bfd_iovec Index: cache.c =================================================================== RCS file: /cvs/src/src/bfd/cache.c,v retrieving revision 1.27 diff -u -p -r1.27 cache.c --- cache.c 27 Oct 2005 05:31:16 -0000 1.27 +++ cache.c 3 Nov 2005 15:47:23 -0000 @@ -476,15 +476,15 @@ bfd_open_file (bfd *abfd) { case read_direction: case no_direction: - abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB); + abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RB); break; case both_direction: case write_direction: if (abfd->opened_once) { - abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB); + abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RUB); if (abfd->iostream == NULL) - abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB); + abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); } else { @@ -514,7 +514,7 @@ bfd_open_file (bfd *abfd) if (stat (abfd->filename, &s) == 0 && s.st_size != 0) unlink_if_ordinary (abfd->filename); #endif - abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB); + abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); abfd->opened_once = TRUE; } break; Index: configure.in =================================================================== RCS file: /cvs/src/src/bfd/configure.in,v retrieving revision 1.196 diff -u -p -r1.196 configure.in --- configure.in 25 Oct 2005 17:40:10 -0000 1.196 +++ configure.in 3 Nov 2005 15:47:25 -0000 @@ -921,7 +921,7 @@ AC_SUBST(bfd_default_target_size) # fseeko, long. This assumes that sizeof off_t is .ge. sizeof long. # Hopefully a reasonable assumption since fseeko et.al. should be # upward compatible. -AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64) +AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64 fopen64) if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then AC_CHECK_SIZEOF(off_t) fi Index: libbfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd-in.h,v retrieving revision 1.58 diff -u -p -r1.58 libbfd-in.h --- libbfd-in.h 27 Oct 2005 03:36:57 -0000 1.58 +++ libbfd-in.h 3 Nov 2005 15:47:25 -0000 @@ -651,6 +651,7 @@ extern void _bfd_abort 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); +extern FILE *real_fopen (const char *filename, const char *modes); /* List of supported target vectors, and the default vector (if bfd_default_vector[0] is NULL, there is no default). */ Index: opncls.c =================================================================== RCS file: /cvs/src/src/bfd/opncls.c,v retrieving revision 1.40 diff -u -p -r1.40 opncls.c --- opncls.c 5 Oct 2005 21:24:23 -0000 1.40 +++ opncls.c 3 Nov 2005 15:47:26 -0000 @@ -175,7 +175,7 @@ bfd_fopen (const char *filename, const c nbfd->iostream = fdopen (fd, mode); else #endif - nbfd->iostream = fopen (filename, mode); + nbfd->iostream = real_fopen (filename, mode); if (nbfd->iostream == NULL) { bfd_set_error (bfd_error_system_call); @@ -1407,7 +1407,7 @@ bfd_fill_in_gnu_debuglink_section (bfd * .gnu_debuglink section, we insist upon the user providing us with a correct-for-section-creation-time path, but this need not conform to the gdb location algorithm. */ - handle = fopen (filename, FOPEN_RB); + handle = real_fopen (filename, FOPEN_RB); if (handle == NULL) { bfd_set_error (bfd_error_system_call);