components/binutils/patches/output.cc.patch
author Shawn Emery <shawn.emery@oracle.com>
Fri, 25 Sep 2015 15:23:48 -0500
changeset 4906 51866e99eff7
parent 1123 cb43164c5dd1
child 5057 ab1b43bf588f
permissions -rw-r--r--
21839658 Enable the ldap backend for slapd

--- 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)