diff options
author | Ian Lance Taylor <ian@airs.com> | 2009-03-24 18:42:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2009-03-24 18:42:10 +0000 |
commit | f6060a4d43e06a6ca5dd201b069ab9f29aae1b81 (patch) | |
tree | 61b8f7f3f1bf993a489dd496844d0b3a481762b6 /gold/archive.cc | |
parent | 34274ccc6a1febcac41329a6103eff8880630825 (diff) | |
download | fsf-binutils-gdb-f6060a4d43e06a6ca5dd201b069ab9f29aae1b81.zip fsf-binutils-gdb-f6060a4d43e06a6ca5dd201b069ab9f29aae1b81.tar.gz fsf-binutils-gdb-f6060a4d43e06a6ca5dd201b069ab9f29aae1b81.tar.bz2 |
* object.cc (is_elf_object): Define.
* object.h (is_elf_object): Declare.
* archive.cc (Archive::get_elf_object_for_member): Call
is_elf_object.
* readsymc.cc (Read_symbols::do_read_symbols): Likewise.
Diffstat (limited to 'gold/archive.cc')
-rw-r--r-- | gold/archive.cc | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/gold/archive.cc b/gold/archive.cc index 1d83d6a..2dec571 100644 --- a/gold/archive.cc +++ b/gold/archive.cc @@ -540,27 +540,9 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured) } } - off_t filesize = input_file->file().filesize(); - int read_size = elfcpp::Elf_sizes<64>::ehdr_size; - if (filesize - memoff < read_size) - read_size = filesize - memoff; - - if (read_size < 4) - { - gold_error(_("%s: member at %zu is not an ELF object"), - this->name().c_str(), static_cast<size_t>(off)); - return NULL; - } - - 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, elfmagic, 4) != 0) + const unsigned char* ehdr; + int read_size; + if (!is_elf_object(input_file, memoff, &ehdr, &read_size)) { gold_error(_("%s: member at %zu is not an ELF object"), this->name().c_str(), static_cast<size_t>(off)); |