off_t filesize = this->input_file_->file().filesize();
   while (true)
     {
-      if (filesize - off < sizeof(Archive_header))
+      if (filesize - off < static_cast<off_t>(sizeof(Archive_header)))
         {
           if (filesize != off)
             {
   std::string n;
   this->read_header(off, &n);
 
-  size_t memoff = off + sizeof(Archive_header);
+  const off_t memoff = off + static_cast<off_t>(sizeof(Archive_header));
 
   // Read enough of the file to pick up the entire ELF header.
   unsigned char ehdr_buf[elfcpp::Elf_sizes<64>::ehdr_size];
 
 
   const int sym_size = This::sym_size;
   const size_t symcount = sd->symbols_size / sym_size;
-  if (symcount * sym_size != sd->symbols_size)
+  if (static_cast<off_t>(symcount * sym_size) != sd->symbols_size)
     {
       fprintf(stderr,
              _("%s: %s: size of dynamic symbols is not "
 
       off_t locsize = dyn_global_index * this->dynsym_section_->entsize();
       dynoff = this->dynsym_section_->offset() + locsize;
       dyncount = (this->dynsym_section_->data_size() - locsize) / symsize;
-      gold_assert(dyncount * symsize
+      gold_assert(static_cast<off_t>(dyncount * symsize)
                  == this->dynsym_section_->data_size() - locsize);
     }
 
 
 
   const int sym_size = This::sym_size;
   size_t symcount = sd->symbols_size / sym_size;
-  if (symcount * sym_size != sd->symbols_size)
+  if (static_cast<off_t>(symcount * sym_size) != sd->symbols_size)
     {
       fprintf(stderr,
              _("%s: %s: size of symbols is not multiple of symbol size\n"),
 
        }
 
       size_t reloc_count = sh_size / reloc_size;
-      if (reloc_count * reloc_size != sh_size)
+      if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
        {
          fprintf(stderr, _("%s: %s: reloc section %u size %lu uneven"),
                  program_name, this->name().c_str(), i,
        }
 
       size_t reloc_count = sh_size / reloc_size;
-      if (reloc_count * reloc_size != sh_size)
+      if (static_cast<off_t>(reloc_count * reloc_size) != sh_size)
        {
          fprintf(stderr, _("%s: %s: reloc section %u size %lu uneven"),
                  program_name, this->name().c_str(), i,