This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch for AIX archive reader



I'm about to commit this, for aix 4.3.3 compatibility in ld.  Tested
by a (linker) bootstrap on rs6000-ibm-aix4.3.3.0.  It turns out
this code never actually worked, it was reading 8-byte values as
4-byte ones.

[No, the linker doesn't work yet.  For one thing, it's missing 64-bit
support.]

-- 
- Geoffrey Keating <geoffk@cygnus.com>

===File ~/patches/cygnus/rs6000-ld-armap.patch==============
2000-08-15  Geoffrey Keating  <geoffk@cygnus.com>

	* coff-rs6000.c (_bfd_xcoff_slurp_armap): Finish implementation
	for large archives.

Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.10
diff -u -p -r1.10 coff-rs6000.c
--- coff-rs6000.c	2000/07/25 19:25:40	1.10
+++ coff-rs6000.c	2000/08/15 23:54:59
@@ -1098,7 +1098,7 @@ _bfd_xcoff_slurp_armap (abfd)
   size_t namlen;
   bfd_size_type sz;
   bfd_byte *contents, *cend;
-  unsigned int c, i;
+  bfd_vma c, i;
   carsym *arsym;
   bfd_byte *p;
 
@@ -1133,6 +1133,33 @@ _bfd_xcoff_slurp_armap (abfd)
 	return false;
 
       sz = strtol (hdr.size, (char **) NULL, 10);
+
+      /* Read in the entire symbol table.  */
+      contents = (bfd_byte *) bfd_alloc (abfd, sz);
+      if (contents == NULL)
+	return false;
+      if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+	return false;
+
+      /* The symbol table starts with a four byte count.  */
+      c = bfd_h_get_32 (abfd, contents);
+      
+      if (c * 4 >= sz)
+	{
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+      
+      bfd_ardata (abfd)->symdefs = ((carsym *)
+				    bfd_alloc (abfd, c * sizeof (carsym)));
+      if (bfd_ardata (abfd)->symdefs == NULL)
+	return false;
+      
+      /* After the count comes a list of four byte file offsets.  */
+      for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
+	   i < c;
+	   ++i, ++arsym, p += 4)
+	arsym->file_offset = bfd_h_get_32 (abfd, p);
     }
   else
     {
@@ -1163,34 +1190,34 @@ _bfd_xcoff_slurp_armap (abfd)
 	 machines) since the field width is 20 and there numbers with more
 	 than 32 bits can be represented.  */
       sz = strtol (hdr.size, (char **) NULL, 10);
-    }
 
-  /* Read in the entire symbol table.  */
-  contents = (bfd_byte *) bfd_alloc (abfd, sz);
-  if (contents == NULL)
-    return false;
-  if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
-    return false;
+      /* Read in the entire symbol table.  */
+      contents = (bfd_byte *) bfd_alloc (abfd, sz);
+      if (contents == NULL)
+	return false;
+      if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+	return false;
 
-  /* The symbol table starts with a four byte count.  */
-  c = bfd_h_get_32 (abfd, contents);
+      /* The symbol table starts with an eight byte count.  */
+      c = bfd_h_get_64 (abfd, contents);
 
-  if (c * 4 >= sz)
-    {
-      bfd_set_error (bfd_error_bad_value);
-      return false;
+      if (c * 8 >= sz)
+	{
+	  bfd_set_error (bfd_error_bad_value);
+	  return false;
+	}
+      
+      bfd_ardata (abfd)->symdefs = ((carsym *)
+				    bfd_alloc (abfd, c * sizeof (carsym)));
+      if (bfd_ardata (abfd)->symdefs == NULL)
+	return false;
+      
+      /* After the count comes a list of eight byte file offsets.  */
+      for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
+	   i < c;
+	   ++i, ++arsym, p += 8)
+	arsym->file_offset = bfd_h_get_64 (abfd, p);
     }
-
-  bfd_ardata (abfd)->symdefs = ((carsym *)
-				bfd_alloc (abfd, c * sizeof (carsym)));
-  if (bfd_ardata (abfd)->symdefs == NULL)
-    return false;
-
-  /* After the count comes a list of four byte file offsets.  */
-  for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
-       i < c;
-       ++i, ++arsym, p += 4)
-    arsym->file_offset = bfd_h_get_32 (abfd, p);
 
   /* After the file offsets come null terminated symbol names.  */
   cend = contents + sz;
============================================================

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]