aboutsummaryrefslogtreecommitdiff
path: root/gold/archive.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-01-02 23:48:49 +0000
committerIan Lance Taylor <iant@google.com>2008-01-02 23:48:49 +0000
commitcb29561284eaa37c5c8967e49a5db0a4064368bf (patch)
treef4e88f9b60483aeb87c7cbfda3445f3da58edcc0 /gold/archive.cc
parent2745d86e69ec4659f39cfe0406948578f791ac4f (diff)
downloadfsf-binutils-gdb-cb29561284eaa37c5c8967e49a5db0a4064368bf.zip
fsf-binutils-gdb-cb29561284eaa37c5c8967e49a5db0a4064368bf.tar.gz
fsf-binutils-gdb-cb29561284eaa37c5c8967e49a5db0a4064368bf.tar.bz2
Reduce the number of system calls. Use readv instead of pread. Do
better handling of cached views.
Diffstat (limited to 'gold/archive.cc')
-rw-r--r--gold/archive.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/gold/archive.cc b/gold/archive.cc
index 53b5cd0..2125608 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -85,7 +85,8 @@ Archive::setup(Task* task)
// The first member of the archive should be the symbol table.
std::string armap_name;
section_size_type armap_size =
- convert_to_section_size_type(this->read_header(sarmag, &armap_name));
+ convert_to_section_size_type(this->read_header(sarmag, false,
+ &armap_name));
off_t off = sarmag;
if (armap_name.empty())
{
@@ -96,15 +97,18 @@ Archive::setup(Task* task)
gold_error(_("%s: no archive symbol table (run ranlib)"),
this->name().c_str());
- // See if there is an extended name table.
+ // See if there is an extended name table. We cache these views
+ // because it is likely that we will want to read the following
+ // header in the add_symbols routine.
if ((off & 1) != 0)
++off;
std::string xname;
- off_t extended_size = this->read_header(off, &xname);
+ section_size_type extended_size =
+ convert_to_section_size_type(this->read_header(off, true, &xname));
if (xname == "/")
{
const unsigned char* p = this->get_view(off + sizeof(Archive_header),
- extended_size, false);
+ extended_size, true);
const char* px = reinterpret_cast<const char*>(p);
this->extended_names_.assign(px, extended_size);
}
@@ -157,9 +161,9 @@ Archive::read_armap(off_t start, section_size_type size)
// of the member.
off_t
-Archive::read_header(off_t off, std::string* pname)
+Archive::read_header(off_t off, bool cache, std::string* pname)
{
- const unsigned char* p = this->get_view(off, sizeof(Archive_header), false);
+ const unsigned char* p = this->get_view(off, sizeof(Archive_header), cache);
const Archive_header* hdr = reinterpret_cast<const Archive_header*>(p);
return this->interpret_header(hdr, off, pname);
}
@@ -370,7 +374,7 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
Input_objects* input_objects, off_t off)
{
std::string n;
- this->read_header(off, &n);
+ this->read_header(off, false, &n);
const off_t memoff = off + static_cast<off_t>(sizeof(Archive_header));