large file tweaks

Alan Modra amodra@bigpond.net.au
Mon Nov 20 02:09:00 GMT 2006


Fixes some obvious problems I noticed when looking at what needs to be
done to support large files.  There are probably other things that
need tweaking too.

	* bfd-in.h (struct stat): Don't typedef.
	* bfdio.c (bfd_get_size): Return a file_ptr.
	* cisco-core.c (cisco_core_file_validate): Use bfd_size_type for nread.
	* mmo.c (mmo_scan): Use file_ptr for curpos.
	* trad-core.c (trad_unix_core): Don't cast statbuf.st_size to
	unsigned long.
	* bfd-in2.h: Regenerate.

Index: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.120
diff -u -p -r1.120 bfd-in.h
--- bfd/bfd-in.h	13 Nov 2006 20:39:21 -0000	1.120
+++ bfd/bfd-in.h	15 Nov 2006 00:29:31 -0000
@@ -350,7 +350,8 @@ typedef struct bfd_section *sec_ptr;
   (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
    / bfd_octets_per_byte (bfd))
 
-typedef struct stat stat_type;
+/* Forward define.  */
+struct stat;
 
 typedef enum bfd_print_symbol
 {
Index: bfd/bfdio.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdio.c,v
retrieving revision 1.12
diff -u -p -r1.12 bfdio.c
--- bfd/bfdio.c	3 Nov 2005 16:06:10 -0000	1.12
+++ bfd/bfdio.c	15 Nov 2006 00:29:35 -0000
@@ -401,7 +401,7 @@ FUNCTION
 	bfd_get_size
 
 SYNOPSIS
-	long bfd_get_size (bfd *abfd);
+	file_ptr bfd_get_size (bfd *abfd);
 
 DESCRIPTION
 	Return the file size (as read from file system) for the file
@@ -429,7 +429,7 @@ DESCRIPTION
 	size reasonable?".
 */
 
-long
+file_ptr
 bfd_get_size (bfd *abfd)
 {
   struct stat buf;
Index: bfd/cisco-core.c
===================================================================
RCS file: /cvs/src/src/bfd/cisco-core.c,v
retrieving revision 1.13
diff -u -p -r1.13 cisco-core.c
--- bfd/cisco-core.c	1 Jun 2006 03:45:58 -0000	1.13
+++ bfd/cisco-core.c	15 Nov 2006 00:29:35 -0000
@@ -88,7 +88,7 @@ cisco_core_file_validate (abfd, crash_in
   char buf[4];
   unsigned int crashinfo_offset;
   crashinfo_external crashinfo;
-  int nread;
+  bfd_size_type nread;
   unsigned int magic;
   unsigned int version;
   unsigned int rambase;
Index: bfd/mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.32
diff -u -p -r1.32 mmo.c
--- bfd/mmo.c	16 Sep 2006 18:12:14 -0000	1.32
+++ bfd/mmo.c	15 Nov 2006 00:29:37 -0000
@@ -1917,7 +1917,7 @@ mmo_scan (bfd *abfd)
 		/* This must be the last 32-bit word in an mmo file.
 		   Let's find out.  */
 		struct stat statbuf;
-		long curpos = bfd_tell (abfd);
+		file_ptr curpos = bfd_tell (abfd);
 
 		if (bfd_stat (abfd, &statbuf) < 0)
 		  goto error_return;
Index: bfd/trad-core.c
===================================================================
RCS file: /cvs/src/src/bfd/trad-core.c,v
retrieving revision 1.24
diff -u -p -r1.24 trad-core.c
--- bfd/trad-core.c	1 Jun 2006 03:45:58 -0000	1.24
+++ bfd/trad-core.c	15 Nov 2006 00:29:38 -0000
@@ -114,24 +114,24 @@ trad_unix_core_file_p (abfd)
     if (bfd_stat (abfd, &statbuf) < 0)
       return 0;
 
-    if ((unsigned long) (NBPG * (UPAGES + u.u_dsize
+    if ((ufile_ptr) NBPG * (UPAGES + u.u_dsize
 #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
-				 - u.u_tsize
+			    - u.u_tsize
 #endif
-				 + u.u_ssize))
-	> (unsigned long) statbuf.st_size)
+			    + u.u_ssize)
+	> (ufile_ptr) statbuf.st_size)
       {
 	bfd_set_error (bfd_error_wrong_format);
 	return 0;
       }
 #ifndef TRAD_CORE_ALLOW_ANY_EXTRA_SIZE
-    if ((unsigned long) (NBPG * (UPAGES + u.u_dsize + u.u_ssize)
+    if (((ufile_ptr) NBPG * (UPAGES + u.u_dsize + u.u_ssize)
 #ifdef TRAD_CORE_EXTRA_SIZE_ALLOWED
 	/* Some systems write the file too big.  */
-			 + TRAD_CORE_EXTRA_SIZE_ALLOWED
+	 + TRAD_CORE_EXTRA_SIZE_ALLOWED
 #endif
-			 )
-	< (unsigned long) statbuf.st_size)
+	 )
+	< (ufile_ptr) statbuf.st_size)
       {
 	/* The file is too big.  Maybe it's not a core file
 	   or we otherwise have bad values for u_dsize and u_ssize).  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list