From f6060a4d43e06a6ca5dd201b069ab9f29aae1b81 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 24 Mar 2009 18:42:10 +0000 Subject: * 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. --- gold/archive.cc | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'gold/archive.cc') 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(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(off)); -- cgit v1.1