summaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-04-23 17:29:04 +0000
committerIan Lance Taylor <ian@airs.com>2008-04-23 17:29:04 +0000
commit38d9167f5d97be0fb9aff9057a5797c5b25b3886 (patch)
treed7b2dcd0c5c58742df93231a5ca4c74e4d8bfc4c /gold
parent23d07e8dd87e1ad8e7811bc8e6a73d9cd5dff1ed (diff)
downloadbinutils-redhat-38d9167f5d97be0fb9aff9057a5797c5b25b3886.tar.gz
* readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
than read for file header. * archive.cc (Archive::include_member): Likewise.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog6
-rw-r--r--gold/archive.cc11
-rw-r--r--gold/readsyms.cc13
3 files changed, 16 insertions, 14 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index bd4b9d2710..3c4cbda9b2 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-23 Ian Lance Taylor <iant@google.com>
+
+ * readsyms.cc (Read_symbols::do_read_symbols): Use get_view rather
+ than read for file header.
+ * archive.cc (Archive::include_member): Likewise.
+
2008-04-23 Paolo Bonzini <bonzini@gnu.org>
* aclocal.m4: Regenerate.
diff --git a/gold/archive.cc b/gold/archive.cc
index 25708ee4b6..be623b511d 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -464,9 +464,6 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
memoff = 0;
}
- // Read enough of the file to pick up the entire ELF header.
- unsigned char ehdr_buf[elfcpp::Elf_sizes<64>::ehdr_size];
-
off_t filesize = input_file->file().filesize();
int read_size = elfcpp::Elf_sizes<64>::ehdr_size;
if (filesize - memoff < read_size)
@@ -479,14 +476,15 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
return;
}
- input_file->file().read(memoff, read_size, ehdr_buf);
+ const unsigned char* ehdr = input_file->file().get_view(memoff, 0, read_size,
+ true, false);
static unsigned char elfmagic[4] =
{
elfcpp::ELFMAG0, elfcpp::ELFMAG1,
elfcpp::ELFMAG2, elfcpp::ELFMAG3
};
- if (memcmp(ehdr_buf, elfmagic, 4) != 0)
+ if (memcmp(ehdr, elfmagic, 4) != 0)
{
gold_error(_("%s: member at %zu is not an ELF object"),
this->name().c_str(), static_cast<size_t>(off));
@@ -495,8 +493,7 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
Object* obj = make_elf_object((std::string(this->input_file_->filename())
+ "(" + n + ")"),
- input_file, memoff, ehdr_buf,
- read_size);
+ input_file, memoff, ehdr, read_size);
if (input_objects->add_object(obj))
{
diff --git a/gold/readsyms.cc b/gold/readsyms.cc
index d0bf2644a4..18b91b42b7 100644
--- a/gold/readsyms.cc
+++ b/gold/readsyms.cc
@@ -152,13 +152,12 @@ Read_symbols::do_read_symbols(Workqueue* workqueue)
return false;
}
- unsigned char ehdr_buf[elfcpp::Elf_sizes<64>::ehdr_size];
-
int read_size = elfcpp::Elf_sizes<64>::ehdr_size;
if (filesize < read_size)
read_size = filesize;
- input_file->file().read(0, read_size, ehdr_buf);
+ const unsigned char* ehdr = input_file->file().get_view(0, 0, read_size,
+ true, false);
if (read_size >= 4)
{
@@ -167,12 +166,12 @@ Read_symbols::do_read_symbols(Workqueue* workqueue)
elfcpp::ELFMAG0, elfcpp::ELFMAG1,
elfcpp::ELFMAG2, elfcpp::ELFMAG3
};
- if (memcmp(ehdr_buf, elfmagic, 4) == 0)
+ if (memcmp(ehdr, elfmagic, 4) == 0)
{
// This is an ELF object.
Object* obj = make_elf_object(input_file->filename(),
- input_file, 0, ehdr_buf, read_size);
+ input_file, 0, ehdr, read_size);
if (obj == NULL)
return false;
@@ -205,9 +204,9 @@ Read_symbols::do_read_symbols(Workqueue* workqueue)
if (read_size >= Archive::sarmag)
{
bool is_thin_archive
- = memcmp(ehdr_buf, Archive::armagt, Archive::sarmag) == 0;
+ = memcmp(ehdr, Archive::armagt, Archive::sarmag) == 0;
if (is_thin_archive
- || memcmp(ehdr_buf, Archive::armag, Archive::sarmag) == 0)
+ || memcmp(ehdr, Archive::armag, Archive::sarmag) == 0)
{
// This is an archive.
Archive* arch = new Archive(this->input_argument_->file().name(),