components/binutils/patches/output.cc.patch
changeset 1123 cb43164c5dd1
child 5057 ab1b43bf588f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/binutils/patches/output.cc.patch	Wed Jan 16 09:05:17 2013 -0800
@@ -0,0 +1,29 @@
+--- binutils-2.23.1/gold/output.cc	2012-11-09 01:21:28.000000000 -0700
++++ binutils-2.23.1/gold/output.cc	2013-01-01 01:45:50.721203685 -0700
+@@ -22,6 +22,7 @@
+ 
+ #include "gold.h"
+ 
++#include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
+ #include <cerrno>
+@@ -127,9 +128,15 @@
+ static int
+ gold_fallocate(int o, off_t offset, off_t len)
+ {
+-#ifdef HAVE_POSIX_FALLOCATE
+-  if (parameters->options().posix_fallocate())
+-    return ::posix_fallocate(o, offset, len);
++#if defined(HAVE_POSIX_FALLOCATE)
++  if (parameters->options().posix_fallocate()) {
++    // posix_fallocate on Solaris will fail if len == 0
++    int ret = ::posix_fallocate(o, offset, len);
++    // try ::ftruncate(3C) is posix_fallocate(3C) failed.
++    if (ret != 0)
++      ret = ::ftruncate(o, offset + len);
++    return ret;
++  }
+ #endif // defined(HAVE_POSIX_FALLOCATE)
+ #ifdef HAVE_FALLOCATE
+   if (::fallocate(o, 0, offset, len) == 0)