22199341 libbfd's file caching scheme bombs in 32-bit
authorStefan Teleman <stefan.teleman@oracle.com>
Thu, 19 Nov 2015 14:12:20 -0800
changeset 5110 92c73cda9414
parent 5109 5d341c4a6b80
child 5111 e68e059c3456
22199341 libbfd's file caching scheme bombs in 32-bit
components/binutils/patches/cache.c.patch
components/binutils/patches/ihex.c.patch
components/binutils/patches/srec.c.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/binutils/patches/cache.c.patch	Thu Nov 19 14:12:20 2015 -0800
@@ -0,0 +1,28 @@
+# Patch submitted to the binutils project:
+# https://sourceware.org/bugzilla/show_bug.cgi?id=19260
+--- bfd/cache.c	2014-10-14 00:32:02.000000000 -0700
++++ bfd/cache.c	2015-11-17 21:23:28.679754360 -0800
[email protected]@ -77,6 +77,23 @@
+ {
+   if (max_open_files == 0)
+     {
++#if defined(__sun) && !defined(__sparcv9) && !defined(__x86_64__)
++      /* Very inelegant handling of the 255 file descriptor limit
++       * in 32-bit Solaris libc.
++       * The problem is that setrlimit(2) can raise RLIMIT_NOFILE
++       * in 32-bit to a value that is not supported by libc, resulting
++       * in "Too many open files" errors.
++       * This can happen even if max_open_files = rlim.rlim_cur / 8.
++       * For example, if rlim.rlim_cur == 65536, then max_open_files == 8192.
++       * This essentially reverts to the behavior from binutils 2.23.1
++       * for 32-bit Solaris only.
++       * We hope to have this 32-bit libc limitation removed soon.
++       * 64-bit Solaris libc does not have this limitation.
++       */
++      max_open_files = 16;
++      return max_open_files;
++#endif
++
+       int max;
+ #ifdef HAVE_GETRLIMIT
+       struct rlimit rlim;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/binutils/patches/ihex.c.patch	Thu Nov 19 14:12:20 2015 -0800
@@ -0,0 +1,31 @@
+# Patch is from RedHat binutils-2.25.1 src rpm.
+# No need to send to binutils, they know about it.
+--- bfd/ihex.c	2014-11-04 01:54:41.000000000 -0800
++++ bfd/ihex.c	2015-11-14 22:31:59.559502520 -0800
[email protected]@ -219,7 +219,7 @@
+       char buf[10];
+ 
+       if (! ISPRINT (c))
+-	sprintf (buf, "\\%03o", (unsigned int) c);
++	sprintf (buf, "\\%03o", (unsigned int) (c & 0xff));
+       else
+ 	{
+ 	  buf[0] = c;
[email protected]@ -276,7 +276,7 @@
+       else
+ 	{
+ 	  file_ptr pos;
+-	  char hdr[8];
++	  unsigned char hdr[8];
+ 	  unsigned int i;
+ 	  unsigned int len;
+ 	  bfd_vma addr;
[email protected]@ -553,7 +553,7 @@
+   error = FALSE;
+   while ((c = ihex_get_byte (abfd, &error)) != EOF)
+     {
+-      char hdr[8];
++      unsigned char hdr[8];
+       unsigned int len;
+       unsigned int type;
+       unsigned int i;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/binutils/patches/srec.c.patch	Thu Nov 19 14:12:20 2015 -0800
@@ -0,0 +1,13 @@
+# Patch is from RedHat binutils-2.25.1 src rpm.
+# No need to send to binutils, they know about it.
+--- bfd/srec.c	2014-11-04 01:54:41.000000000 -0800
++++ bfd/srec.c	2015-11-14 22:32:41.094053576 -0800
[email protected]@ -249,7 +249,7 @@
+       char buf[40];
+ 
+       if (! ISPRINT (c))
+-	sprintf (buf, "\\%03o", (unsigned int) c);
++	sprintf (buf, "\\%03o", (unsigned int) (c & 0xff));
+       else
+ 	{
+ 	  buf[0] = c;