aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-10-18 21:36:29 +0000
committerCary Coutant <ccoutant@google.com>2011-10-18 21:36:29 +0000
commitbab9090fa32be3fd43bef52ff7a17531964f10fb (patch)
tree0edb48a7ea507fe0df73b1f0c432d7d6bde7eaf1 /gold
parent736086bae2e0c54fa5f59d332a383af1e2f6d8d8 (diff)
downloadgdb-bab9090fa32be3fd43bef52ff7a17531964f10fb.zip
gdb-bab9090fa32be3fd43bef52ff7a17531964f10fb.tar.gz
gdb-bab9090fa32be3fd43bef52ff7a17531964f10fb.tar.bz2
* output.cc (posix_fallocate): Return 0 on success, errno on failure.
(Output_file::map_no_anonymous): Check for non-zero return code from posix_fallocate.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog6
-rw-r--r--gold/output.cc12
2 files changed, 15 insertions, 3 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 1833996..61ad6cd 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-18 Cary Coutant <ccoutant@google.com>
+
+ * output.cc (posix_fallocate): Return 0 on success, errno on failure.
+ (Output_file::map_no_anonymous): Check for non-zero
+ return code from posix_fallocate.
+
2011-10-17 Cary Coutant <ccoutant@google.com>
PR gold/13245
diff --git a/gold/output.cc b/gold/output.cc
index 7b272e8..7633c73 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -119,7 +119,9 @@ extern "C" void *gold_mremap(void *, size_t, size_t, int);
static int
posix_fallocate(int o, off_t offset, off_t len)
{
- return ftruncate(o, offset + len);
+ if (ftruncate(o, offset + len) < 0)
+ return errno;
+ return 0;
}
#endif // !defined(HAVE_POSIX_FALLOCATE)
@@ -5075,8 +5077,12 @@ Output_file::map_no_anonymous(bool writable)
// output file will wind up incomplete, but we will have already
// exited. The alternative to fallocate would be to use fdatasync,
// but that would be a more significant performance hit.
- if (writable && ::posix_fallocate(o, 0, this->file_size_) < 0)
- gold_fatal(_("%s: %s"), this->name_, strerror(errno));
+ if (writable)
+ {
+ int err = ::posix_fallocate(o, 0, this->file_size_);
+ if (err != 0)
+ gold_fatal(_("%s: %s"), this->name_, strerror(err));
+ }
// Map the file into memory.
int prot = PROT_READ;