Hello,

Here is the 2 patches I needed in order to build binutils and gcc with
rockboxdev.sh

The patch for binutils is needed for correct runtime: arm-elf-ar would
build but crash because of a buffer overflow.

-- 
Rafaël Carré
diff -ru binutils-2.16.1.orig/bfd/archive.c binutils-2.16.1/bfd/archive.c
--- binutils-2.16.1.orig/bfd/archive.c  2005-03-03 12:40:56.000000000 +0100
+++ binutils-2.16.1/bfd/archive.c       2008-10-29 16:43:20.000000000 +0100
@@ -1660,7 +1660,7 @@
       memset (&hdr, 0, sizeof (struct ar_hdr));
       strcpy (hdr.ar_name, ename);
       /* Round size up to even number in archive header.  */
-      sprintf (&(hdr.ar_size[0]), "%-10d",
+      snprintf (&(hdr.ar_size[0]), sizeof(hdr.ar_size), "%-10d",
               (int) ((elength + 1) & ~(bfd_size_type) 1));
       strncpy (hdr.ar_fmag, ARFMAG, 2);
       for (i = 0; i < sizeof (struct ar_hdr); i++)
@@ -2068,12 +2068,12 @@
 
   memset (&hdr, 0, sizeof (struct ar_hdr));
   hdr.ar_name[0] = '/';
-  sprintf (hdr.ar_size, "%-10d", (int) mapsize);
-  sprintf (hdr.ar_date, "%ld", (long) time (NULL));
+  snprintf (hdr.ar_size, sizeof(hdr.ar_size), "%-10d", (int) mapsize);
+  snprintf (hdr.ar_date, sizeof(hdr.ar_date), "%ld", (long) time (NULL));
   /* This, at least, is what Intel coff sets the values to.  */
-  sprintf ((hdr.ar_uid), "%d", 0);
-  sprintf ((hdr.ar_gid), "%d", 0);
-  sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
+  snprintf ((hdr.ar_uid), sizeof(hdr.ar_uid), "%d", 0);
+  snprintf ((hdr.ar_gid), sizeof(hdr.ar_gid), "%d", 0);
+  snprintf ((hdr.ar_mode), sizeof(hdr.ar_mode), "%-7o", (unsigned) 0);
   strncpy (hdr.ar_fmag, ARFMAG, 2);
 
   for (i = 0; i < sizeof (struct ar_hdr); i++)
--- gcc-4.0.3/gcc/collect2.c.orig       2005-06-06 21:21:03.000000000 +0200
+++ gcc-4.0.3/gcc/collect2.c    2008-10-29 15:31:13.000000000 +0100
@@ -1577,7 +1577,8 @@
   if (redir)
     {
       /* Open response file.  */
-      redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
+      redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT,
+        S_IRUSR | S_IWUSR);
 
       /* Duplicate the stdout and stderr file handles
         so they can be restored later.  */

Reply via email to