diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-03-09 01:50:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-03-09 01:50:33 +0000 |
commit | ecb351e91911d22855384ff4a04041c351dd33a7 (patch) | |
tree | de6f50a5b4c32d5ca8776af7e55e44e2e4a13e0b /gold/fileread.cc | |
parent | 98689b250438e851b5d33e7806bb35cfbba19ba3 (diff) | |
download | gdb-ecb351e91911d22855384ff4a04041c351dd33a7.zip gdb-ecb351e91911d22855384ff4a04041c351dd33a7.tar.gz gdb-ecb351e91911d22855384ff4a04041c351dd33a7.tar.bz2 |
PR gold/12525
* fileread.cc: #include <climits>.
(GOLD_IOV_MAX): Define.
(File_read::read_multiple): Limit number of entries by iov_max.
* fileread.h (class File_read): Always set max_readv_entries to
128.
Diffstat (limited to 'gold/fileread.cc')
-rw-r--r-- | gold/fileread.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc index 14a02b2..654e47b 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -1,6 +1,6 @@ // fileread.cc -- read files for gold -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of gold. @@ -24,6 +24,7 @@ #include <cstring> #include <cerrno> +#include <climits> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> @@ -605,11 +606,22 @@ File_read::do_readv(off_t base, const Read_multiple& rm, size_t start, got, want, static_cast<long long>(base + first_offset)); } +// Portable IOV_MAX. + +#if !defined(HAVE_READV) +#define GOLD_IOV_MAX 1 +#elif defined(IOV_MAX) +#define GOLD_IOV_MAX IOV_MAX +#else +#define GOLD_IOV_MAX (File_read::max_readv_entries * 2) +#endif + // Read several pieces of data from the file. void File_read::read_multiple(off_t base, const Read_multiple& rm) { + static size_t iov_max = GOLD_IOV_MAX; size_t count = rm.size(); size_t i = 0; while (i < count) @@ -622,7 +634,7 @@ File_read::read_multiple(off_t base, const Read_multiple& rm) size_t j; for (j = i + 1; j < count; ++j) { - if (j - i >= File_read::max_readv_entries) + if (j - i >= File_read::max_readv_entries || j - i >= iov_max / 2) break; const Read_multiple_entry& j_entry(rm[j]); off_t j_off = j_entry.file_offset; |