Convert more instances of off_t to be 32-bit types.
authorIan Lance Taylor <iant@google.com>
Thu, 20 Dec 2007 21:21:24 +0000 (21:21 +0000)
committerIan Lance Taylor <iant@google.com>
Thu, 20 Dec 2007 21:21:24 +0000 (21:21 +0000)
12 files changed:
gold/fileread.cc
gold/fileread.h
gold/i386.cc
gold/output.h
gold/reloc.cc
gold/symtab.cc
gold/symtab.h
gold/target-reloc.h
gold/target.h
gold/testsuite/testfile.cc
gold/tls.h
gold/x86_64.cc

index 30501548de4295162464ba5b488e781f6a5ef55b..31f48a4462370760f14b6aa4452095b3f01185c0 100644 (file)
@@ -206,9 +206,9 @@ File_read::find_view(off_t start, section_size_type size) const
 // the buffer at P.
 
 void
-File_read::do_read(off_t start, off_t size, void* p) const
+File_read::do_read(off_t start, section_size_type size, void* p) const
 {
-  off_t bytes;
+  section_size_type bytes;
   if (this->contents_ != NULL)
     {
       bytes = this->size_ - start;
@@ -220,16 +220,16 @@ File_read::do_read(off_t start, off_t size, void* p) const
     }
   else
     {
-      bytes = ::pread(this->descriptor_, p, size, start);
-      if (bytes == size)
-       return;
-
-      if (bytes < 0)
+      ssize_t got = ::pread(this->descriptor_, p, size, start);
+      if (got < 0)
        {
          gold_fatal(_("%s: pread failed: %s"),
                     this->filename().c_str(), strerror(errno));
          return;
        }
+
+      if (static_cast<section_size_type>(got) == size)
+       return;
     }
 
   gold_fatal(_("%s: file too short: read only %lld of %lld bytes at %lld"),
@@ -242,7 +242,7 @@ File_read::do_read(off_t start, off_t size, void* p) const
 // Read data from the file.
 
 void
-File_read::read(off_t start, off_t size, void* p) const
+File_read::read(off_t start, section_size_type size, void* p) const
 {
   File_read::View* pv = this->find_view(start, size);
   if (pv != NULL)
@@ -286,12 +286,12 @@ File_read::find_or_make_view(off_t start, section_size_type size, bool cache)
   // We need to read data from the file.  We read full pages for
   // greater efficiency on small files.
 
-  off_t psize = File_read::pages(size + (start - poff));
+  section_size_type psize = File_read::pages(size + (start - poff));
 
   if (poff + psize >= this->size_)
     {
       psize = this->size_ - poff;
-      gold_assert(psize >= static_cast<off_t>(size));
+      gold_assert(psize >= size);
     }
 
   File_read::View* v;
index 088a76b46683466f125e7aa346bf72f84f63ede8..1c47f24e47c81e8eea825deeb3053166902f5cee 100644 (file)
@@ -115,7 +115,7 @@ class File_read
   // Read data from the file into the buffer P starting at file offset
   // START for SIZE bytes.
   void
-  read(off_t start, off_t size, void* p) const;
+  read(off_t start, section_size_type size, void* p) const;
 
   // Return a lasting view into the file starting at file offset START
   // for SIZE bytes.  This is allocated with new, and the caller is
@@ -209,7 +209,7 @@ class File_read
 
   // Read data from the file into a buffer.
   void
-  do_read(off_t start, off_t size, void* p) const;
+  do_read(off_t start, section_size_type size, void* p) const;
 
   // Find or make a view into the file.
   View*
index 76719107b1e8d902a4f70cf339a7c271e1984b4c..0858e6d149c315bfa3c4be8ecd9a26f46b579c64 100644 (file)
@@ -94,11 +94,11 @@ class Target_i386 : public Sized_target<32, false>
                   bool needs_special_offset_handling,
                   unsigned char* view,
                   elfcpp::Elf_types<32>::Elf_Addr view_address,
-                  off_t view_size);
+                  section_size_type view_size);
 
   // Return a string used to fill a code section with nops.
   std::string
-  do_code_fill(off_t length);
+  do_code_fill(section_size_type length);
 
   // Return whether SYM is defined by the ABI.
   bool
@@ -106,7 +106,7 @@ class Target_i386 : public Sized_target<32, false>
   { return strcmp(sym->name(), "___tls_get_addr") == 0; }
 
   // Return the size of the GOT section.
-  off_t
+  section_size_type
   got_size()
   {
     gold_assert(this->got_ != NULL);
@@ -176,7 +176,7 @@ class Target_i386 : public Sized_target<32, false>
             unsigned int r_type, const Sized_symbol<32>*,
             const Symbol_value<32>*,
             unsigned char*, elfcpp::Elf_types<32>::Elf_Addr,
-            off_t);
+            section_size_type);
 
    private:
     // Do a TLS relocation.
@@ -185,7 +185,8 @@ class Target_i386 : public Sized_target<32, false>
                  size_t relnum, const elfcpp::Rel<32, false>&,
                 unsigned int r_type, const Sized_symbol<32>*,
                 const Symbol_value<32>*,
-                unsigned char*, elfcpp::Elf_types<32>::Elf_Addr, off_t);
+                unsigned char*, elfcpp::Elf_types<32>::Elf_Addr,
+                section_size_type);
 
     // Do a TLS General-Dynamic to Initial-Exec transition.
     inline void
@@ -194,7 +195,7 @@ class Target_i386 : public Sized_target<32, false>
                 const elfcpp::Rel<32, false>&, unsigned int r_type,
                 elfcpp::Elf_types<32>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS General-Dynamic to Local-Exec transition.
     inline void
@@ -203,7 +204,7 @@ class Target_i386 : public Sized_target<32, false>
                 const elfcpp::Rel<32, false>&, unsigned int r_type,
                 elfcpp::Elf_types<32>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS Local-Dynamic to Local-Exec transition.
     inline void
@@ -212,7 +213,7 @@ class Target_i386 : public Sized_target<32, false>
                 const elfcpp::Rel<32, false>&, unsigned int r_type,
                 elfcpp::Elf_types<32>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS Initial-Exec to Local-Exec transition.
     static inline void
@@ -221,7 +222,7 @@ class Target_i386 : public Sized_target<32, false>
                 const elfcpp::Rel<32, false>&, unsigned int r_type,
                 elfcpp::Elf_types<32>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // We need to keep track of which type of local dynamic relocation
     // we have seen, so that we can optimize R_386_TLS_LDO_32 correctly.
@@ -473,7 +474,7 @@ Output_data_plt_i386::add_entry(Symbol* gsym)
 
   ++this->count_;
 
-  off_t got_offset = this->got_plt_->current_data_size();
+  section_offset_type got_offset = this->got_plt_->current_data_size();
 
   // Every PLT entry needs a GOT entry which points back to the PLT
   // entry (this will be changed by the dynamic linker, normally
@@ -542,11 +543,13 @@ void
 Output_data_plt_i386::do_write(Output_file* of)
 {
   const off_t offset = this->offset();
-  const off_t oview_size = this->data_size();
+  const section_size_type oview_size =
+    convert_to_section_size_type(this->data_size());
   unsigned char* const oview = of->get_output_view(offset, oview_size);
 
   const off_t got_file_offset = this->got_plt_->offset();
-  const off_t got_size = this->got_plt_->data_size();
+  const section_size_type got_size =
+    convert_to_section_size_type(this->got_plt_->data_size());
   unsigned char* const got_view = of->get_output_view(got_file_offset,
                                                      got_size);
 
@@ -608,8 +611,8 @@ Output_data_plt_i386::do_write(Output_file* of)
       elfcpp::Swap<32, false>::writeval(got_pov, plt_address + plt_offset + 6);
     }
 
-  gold_assert(pov - oview == oview_size);
-  gold_assert(got_pov - got_view == got_size);
+  gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
+  gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size);
 
   of->write_output_view(offset, oview_size, oview);
   of->write_output_view(got_file_offset, got_size, got_view);
@@ -727,9 +730,10 @@ Target_i386::copy_reloc(const General_options* options,
       if (align > dynbss->addralign())
        dynbss->set_space_alignment(align);
 
-      off_t dynbss_size = dynbss->current_data_size();
+      section_size_type dynbss_size =
+       convert_to_section_size_type(dynbss->current_data_size());
       dynbss_size = align_address(dynbss_size, align);
-      off_t offset = dynbss_size;
+      section_size_type offset = dynbss_size;
       dynbss->set_current_data_size(dynbss_size + symsize);
 
       symtab->define_with_copy_reloc(this, ssym, dynbss, offset);
@@ -1469,7 +1473,7 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
                                const Symbol_value<32>* psymval,
                                unsigned char* view,
                                elfcpp::Elf_types<32>::Elf_Addr address,
-                               off_t view_size)
+                               section_size_type view_size)
 {
   if (this->skip_call_tls_get_addr_)
     {
@@ -1669,7 +1673,7 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo,
                                    const Symbol_value<32>* psymval,
                                    unsigned char* view,
                                    elfcpp::Elf_types<32>::Elf_Addr,
-                                   off_t view_size)
+                                   section_size_type view_size)
 {
   Output_segment* tls_segment = relinfo->layout->tls_segment();
 
@@ -1854,7 +1858,7 @@ Target_i386::Relocate::tls_gd_to_le(const Relocate_info<32, false>* relinfo,
                                    unsigned int,
                                    elfcpp::Elf_types<32>::Elf_Addr value,
                                    unsigned char* view,
-                                   off_t view_size)
+                                   section_size_type view_size)
 {
   // leal foo(,%reg,1),%eax; call ___tls_get_addr
   //  ==> movl %gs:0,%eax; subl $foo@tpoff,%eax
@@ -1885,7 +1889,7 @@ Target_i386::Relocate::tls_gd_to_le(const Relocate_info<32, false>* relinfo,
     {
       tls::check_tls(relinfo, relnum, rel.get_r_offset(),
                      (op1 & 0xf8) == 0x80 && (op1 & 7) != 4);
-      if (static_cast<off_t>(rel.get_r_offset() + 9) < view_size
+      if (rel.get_r_offset() + 9 < view_size
           && view[9] == 0x90)
        {
          // There is a trailing nop.  Use the size byte subl.
@@ -1918,7 +1922,7 @@ Target_i386::Relocate::tls_gd_to_ie(const Relocate_info<32, false>* relinfo,
                                    unsigned int,
                                    elfcpp::Elf_types<32>::Elf_Addr value,
                                    unsigned char* view,
-                                   off_t view_size)
+                                   section_size_type view_size)
 {
   // leal foo(,%ebx,1),%eax; call ___tls_get_addr
   //  ==> movl %gs:0,%eax; addl foo@gotntpoff(%ebx),%eax
@@ -1951,7 +1955,7 @@ Target_i386::Relocate::tls_gd_to_ie(const Relocate_info<32, false>* relinfo,
     {
       tls::check_tls(relinfo, relnum, rel.get_r_offset(),
                      (op1 & 0xf8) == 0x80 && (op1 & 7) != 4);
-      if (static_cast<off_t>(rel.get_r_offset() + 9) < view_size
+      if (rel.get_r_offset() + 9 < view_size
           && view[9] == 0x90)
        {
           // FIXME: This is not the right instruction sequence.
@@ -1986,7 +1990,7 @@ Target_i386::Relocate::tls_ld_to_le(const Relocate_info<32, false>* relinfo,
                                    unsigned int,
                                    elfcpp::Elf_types<32>::Elf_Addr,
                                    unsigned char* view,
-                                   off_t view_size)
+                                   section_size_type view_size)
 {
   // leal foo(%reg), %eax; call ___tls_get_addr
   // ==> movl %gs:0,%eax; nop; leal 0(%esi,1),%esi
@@ -2018,7 +2022,7 @@ Target_i386::Relocate::tls_ie_to_le(const Relocate_info<32, false>* relinfo,
                                    unsigned int r_type,
                                    elfcpp::Elf_types<32>::Elf_Addr value,
                                    unsigned char* view,
-                                   off_t view_size)
+                                   section_size_type view_size)
 {
   // We have to actually change the instructions, which means that we
   // need to examine the opcodes to figure out which instruction we
@@ -2114,7 +2118,7 @@ Target_i386::relocate_section(const Relocate_info<32, false>* relinfo,
                              bool needs_special_offset_handling,
                              unsigned char* view,
                              elfcpp::Elf_types<32>::Elf_Addr address,
-                             off_t view_size)
+                             section_size_type view_size)
 {
   gold_assert(sh_type == elfcpp::SHT_REL);
 
@@ -2147,7 +2151,7 @@ Target_i386::do_dynsym_value(const Symbol* gsym) const
 // the specified length.
 
 std::string
-Target_i386::do_code_fill(off_t length)
+Target_i386::do_code_fill(section_size_type length)
 {
   if (length >= 16)
     {
index a244fa587048f53dbdf1c7dd0d0226262ef8081d..895d70378cc04db4b5a1c0ed2e8033e4e486e4dc 100644 (file)
@@ -2291,44 +2291,44 @@ class Output_file
 
   // Write data to the output file.
   void
-  write(off_t offset, const void* data, off_t len)
+  write(off_t offset, const void* data, size_t len)
   { memcpy(this->base_ + offset, data, len); }
 
   // Get a buffer to use to write to the file, given the offset into
   // the file and the size.
   unsigned char*
-  get_output_view(off_t start, off_t size)
+  get_output_view(off_t start, size_t size)
   {
-    gold_assert(start >= 0 && size >= 0 && start + size <= this->file_size_);
+    gold_assert(start >= 0 && start + size <= this->file_size_);
     return this->base_ + start;
   }
 
   // VIEW must have been returned by get_output_view.  Write the
   // buffer to the file, passing in the offset and the size.
   void
-  write_output_view(off_t, off_t, unsigned char*)
+  write_output_view(off_t, size_t, unsigned char*)
   { }
 
   // Get a read/write buffer.  This is used when we want to write part
   // of the file, read it in, and write it again.
   unsigned char*
-  get_input_output_view(off_t start, off_t size)
+  get_input_output_view(off_t start, size_t size)
   { return this->get_output_view(start, size); }
 
   // Write a read/write buffer back to the file.
   void
-  write_input_output_view(off_t, off_t, unsigned char*)
+  write_input_output_view(off_t, size_t, unsigned char*)
   { }
 
   // Get a read buffer.  This is used when we just want to read part
   // of the file back it in.
   const unsigned char*
-  get_input_view(off_t start, off_t size)
+  get_input_view(off_t start, size_t size)
   { return this->get_output_view(start, size); }
 
   // Release a read bfufer.
   void
-  free_input_view(off_t, off_t, const unsigned char*)
+  free_input_view(off_t, size_t, const unsigned char*)
   { }
 
  private:
index a91c3548cf62877d2fee4c4ec8e21e223517cbce..37a9a85591a1df84f4d222ffd1a39c25ead7fe5a 100644 (file)
@@ -433,16 +433,16 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
        }
 
       off_t view_start;
-      off_t view_size;
+      section_size_type view_size;
       if (output_offset != -1)
        {
          view_start = output_section_offset + output_offset;
-         view_size = shdr.get_sh_size();
+         view_size = convert_to_section_size_type(shdr.get_sh_size());
        }
       else
        {
          view_start = output_section_offset;
-         view_size = output_section_size;
+         view_size = convert_to_section_size_type(output_section_size);
        }
 
       if (view_size == 0)
index afe47da22857352e40d93b7af47cc80ad389b7d1..d39d739978cebf67e190e8664c126b8fc1221520 100644 (file)
@@ -1286,9 +1286,11 @@ Symbol_table::define_symbols(const Layout* layout, const Target* target,
 
 template<int size>
 void
-Symbol_table::define_with_copy_reloc(const Target* target,
-                                    Sized_symbol<size>* csym,
-                                    Output_data* posd, uint64_t value)
+Symbol_table::define_with_copy_reloc(
+    const Target* target,
+    Sized_symbol<size>* csym,
+    Output_data* posd,
+    typename elfcpp::Elf_types<size>::Elf_Addr value)
 {
   gold_assert(csym->is_from_dynobj());
   gold_assert(!csym->is_copied_from_dynobj());
@@ -2175,17 +2177,21 @@ Symbol_table::add_from_dynobj<64, true>(
 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
 template
 void
-Symbol_table::define_with_copy_reloc<32>(const Target* target,
-                                        Sized_symbol<32>* sym,
-                                        Output_data* posd, uint64_t value);
+Symbol_table::define_with_copy_reloc<32>(
+    const Target* target,
+    Sized_symbol<32>* sym,
+    Output_data* posd,
+    elfcpp::Elf_types<32>::Elf_Addr value);
 #endif
 
 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
 template
 void
-Symbol_table::define_with_copy_reloc<64>(const Target* target,
-                                        Sized_symbol<64>* sym,
-                                        Output_data* posd, uint64_t value);
+Symbol_table::define_with_copy_reloc<64>(
+    const Target* target,
+    Sized_symbol<64>* sym,
+    Output_data* posd,
+    elfcpp::Elf_types<64>::Elf_Addr value);
 #endif
 
 #ifdef HAVE_TARGET_32_LITTLE
index 9613f2e08b233777a63f6a7cbab3eff1df743baf..786e5cb5a8019264433f1769784d3302c494c88e 100644 (file)
@@ -1028,7 +1028,8 @@ class Symbol_table
   template<int size>
   void
   define_with_copy_reloc(const Target*, Sized_symbol<size>* sym,
-                        Output_data* posd, uint64_t value);
+                        Output_data* posd,
+                        typename elfcpp::Elf_types<size>::Elf_Addr);
 
   // Look up a symbol.
   Symbol*
index 7c1d327eace01044aea0c98be0d9d9b32b205c39..771869149caaac6a35973edcfb822cd24555a673 100644 (file)
@@ -148,7 +148,7 @@ relocate_section(
     bool needs_special_offset_handling,
     unsigned char* view,
     typename elfcpp::Elf_types<size>::Elf_Addr view_address,
-    off_t view_size)
+    section_size_type view_size)
 {
   typedef typename Reloc_types<sh_type, size, big_endian>::Reloc Reltype;
   const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
@@ -161,7 +161,8 @@ relocate_section(
     {
       Reltype reloc(prelocs);
 
-      off_t offset = reloc.get_r_offset();
+      section_offset_type offset =
+       convert_to_section_size_type(reloc.get_r_offset());
 
       if (needs_special_offset_handling)
        {
@@ -205,7 +206,7 @@ relocate_section(
                             view + offset, view_address + offset, view_size))
        continue;
 
-      if (offset < 0 || offset >= view_size)
+      if (offset < 0 || static_cast<section_size_type>(offset) >= view_size)
        {
          gold_error_at_location(relinfo, i, offset,
                                 _("reloc has bad offset %zu"),
index e385c555d815f40703bc9bc4669a4079d6472441..218d9f757bbdb9d18737afa353c0e17d061c2ae6 100644 (file)
@@ -134,7 +134,7 @@ class Target
   // basically one or more NOPS which must fill out the specified
   // length in bytes.
   std::string
-  code_fill(off_t length)
+  code_fill(section_size_type length)
   { return this->do_code_fill(length); }
 
   // Return whether SYM is known to be defined by the ABI.  This is
@@ -191,7 +191,7 @@ class Target
   // Virtual function which must be implemented by the child class if
   // needed.
   virtual std::string
-  do_code_fill(off_t)
+  do_code_fill(section_size_type)
   { gold_unreachable(); }
 
   // Virtual function which may be implemented by the child class.
@@ -279,7 +279,7 @@ class Sized_target : public Target
                   bool needs_special_offset_handling,
                   unsigned char* view,
                   typename elfcpp::Elf_types<size>::Elf_Addr view_address,
-                  off_t view_size) = 0;
+                  section_size_type view_size) = 0;
 
  protected:
   Sized_target(const Target::Target_info* pti)
index 89bad1d17f91953ea8c8d6888f5336b81ec52a2f..75029ad4309916c6a142d083321854d5665e412c 100644 (file)
@@ -54,7 +54,7 @@ class Target_test : public Sized_target<size, big_endian>
   relocate_section(const Relocate_info<size, big_endian>*, unsigned int,
                   const unsigned char*, size_t, Output_section*, bool,
                   unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr,
-                  off_t)
+                  section_size_type)
   { ERROR("call to Target_test::relocate_section"); }
 
   static const Target::Target_info test_target_info;
index 7103d3febb3ec12e368420df8cc520688978b496..ab20e746e4b72fa765fdfcce12f15ecb5f0e92b1 100644 (file)
@@ -50,10 +50,11 @@ inline void
 check_range(const Relocate_info<size, big_endian>* relinfo,
             size_t relnum,
             typename elfcpp::Elf_types<size>::Elf_Addr rel_offset,
-            off_t view_size, off_t off)
+            section_size_type view_size, int off)
 {
-  off_t offset = rel_offset + off;
-  if (offset < 0 || offset > view_size)
+  typename elfcpp::Elf_types<size>::Elf_Addr offset = rel_offset + off;
+  // Elf_Addr is unsigned, so this also tests for signed offset < 0.
+  if (offset > view_size)
     gold_error_at_location(relinfo, relnum, rel_offset,
                           _("TLS relocation out of range"));
 }
index 6df501d7b9b0fc5074cf05316cc0794711d62183..ddd125d6ee52891da9cf3a600f9e3f0fca25e2e2 100644 (file)
@@ -107,11 +107,11 @@ class Target_x86_64 : public Sized_target<64, false>
                   bool needs_special_offset_handling,
                   unsigned char* view,
                   elfcpp::Elf_types<64>::Elf_Addr view_address,
-                  off_t view_size);
+                  section_size_type view_size);
 
   // Return a string used to fill a code section with nops.
   std::string
-  do_code_fill(off_t length);
+  do_code_fill(section_size_type length);
 
   // Return whether SYM is defined by the ABI.
   bool
@@ -119,7 +119,7 @@ class Target_x86_64 : public Sized_target<64, false>
   { return strcmp(sym->name(), "__tls_get_addr") == 0; }
 
   // Return the size of the GOT section.
-  off_t
+  section_size_type
   got_size()
   {
     gold_assert(this->got_ != NULL);
@@ -181,7 +181,7 @@ class Target_x86_64 : public Sized_target<64, false>
             unsigned int r_type, const Sized_symbol<64>*,
             const Symbol_value<64>*,
             unsigned char*, elfcpp::Elf_types<64>::Elf_Addr,
-            off_t);
+            section_size_type);
 
    private:
     // Do a TLS relocation.
@@ -190,7 +190,8 @@ class Target_x86_64 : public Sized_target<64, false>
                  size_t relnum, const elfcpp::Rela<64, false>&,
                 unsigned int r_type, const Sized_symbol<64>*,
                 const Symbol_value<64>*,
-                unsigned char*, elfcpp::Elf_types<64>::Elf_Addr, off_t);
+                unsigned char*, elfcpp::Elf_types<64>::Elf_Addr,
+                section_size_type);
 
     // Do a TLS General-Dynamic to Local-Exec transition.
     inline void
@@ -199,7 +200,7 @@ class Target_x86_64 : public Sized_target<64, false>
                 const elfcpp::Rela<64, false>&, unsigned int r_type,
                 elfcpp::Elf_types<64>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS General-Dynamic to Local-Exec transition.
     inline void
@@ -208,7 +209,7 @@ class Target_x86_64 : public Sized_target<64, false>
                 const elfcpp::Rela<64, false>&, unsigned int r_type,
                 elfcpp::Elf_types<64>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS Local-Dynamic to Local-Exec transition.
     inline void
@@ -217,7 +218,7 @@ class Target_x86_64 : public Sized_target<64, false>
                 const elfcpp::Rela<64, false>&, unsigned int r_type,
                 elfcpp::Elf_types<64>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // Do a TLS Initial-Exec to Local-Exec transition.
     static inline void
@@ -226,7 +227,7 @@ class Target_x86_64 : public Sized_target<64, false>
                 const elfcpp::Rela<64, false>&, unsigned int r_type,
                 elfcpp::Elf_types<64>::Elf_Addr value,
                 unsigned char* view,
-                off_t view_size);
+                section_size_type view_size);
 
     // This is set if we should skip the next reloc, which should be a
     // PLT32 reloc against ___tls_get_addr.
@@ -462,7 +463,7 @@ Output_data_plt_x86_64::add_entry(Symbol* gsym)
 
   ++this->count_;
 
-  off_t got_offset = this->got_plt_->current_data_size();
+  section_offset_type got_offset = this->got_plt_->current_data_size();
 
   // Every PLT entry needs a GOT entry which points back to the PLT
   // entry (this will be changed by the dynamic linker, normally
@@ -511,11 +512,13 @@ void
 Output_data_plt_x86_64::do_write(Output_file* of)
 {
   const off_t offset = this->offset();
-  const off_t oview_size = this->data_size();
+  const section_size_type oview_size =
+    convert_to_section_size_type(this->data_size());
   unsigned char* const oview = of->get_output_view(offset, oview_size);
 
   const off_t got_file_offset = this->got_plt_->offset();
-  const off_t got_size = this->got_plt_->data_size();
+  const section_size_type got_size =
+    convert_to_section_size_type(this->got_plt_->data_size());
   unsigned char* const got_view = of->get_output_view(got_file_offset,
                                                      got_size);
 
@@ -563,8 +566,8 @@ Output_data_plt_x86_64::do_write(Output_file* of)
       elfcpp::Swap<64, false>::writeval(got_pov, plt_address + plt_offset + 6);
     }
 
-  gold_assert(pov - oview == oview_size);
-  gold_assert(got_pov - got_view == got_size);
+  gold_assert(static_cast<section_size_type>(pov - oview) == oview_size);
+  gold_assert(static_cast<section_size_type>(got_pov - got_view) == got_size);
 
   of->write_output_view(offset, oview_size, oview);
   of->write_output_view(got_file_offset, got_size, got_view);
@@ -683,9 +686,9 @@ Target_x86_64::copy_reloc(const General_options* options,
       if (align > dynbss->addralign())
        dynbss->set_space_alignment(align);
 
-      off_t dynbss_size = dynbss->current_data_size();
+      section_size_type dynbss_size = dynbss->current_data_size();
       dynbss_size = align_address(dynbss_size, align);
-      off_t offset = dynbss_size;
+      section_size_type offset = dynbss_size;
       dynbss->set_current_data_size(dynbss_size + symsize);
 
       symtab->define_with_copy_reloc(this, ssym, dynbss, offset);
@@ -1358,7 +1361,7 @@ Target_x86_64::Relocate::relocate(const Relocate_info<64, false>* relinfo,
                                   const Symbol_value<64>* psymval,
                                   unsigned char* view,
                                   elfcpp::Elf_types<64>::Elf_Addr address,
-                                  off_t view_size)
+                                  section_size_type view_size)
 {
   if (this->skip_call_tls_get_addr_)
     {
@@ -1607,7 +1610,7 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
                                       const Symbol_value<64>* psymval,
                                       unsigned char* view,
                                       elfcpp::Elf_types<64>::Elf_Addr address,
-                                      off_t view_size)
+                                      section_size_type view_size)
 {
   Output_segment* tls_segment = relinfo->layout->tls_segment();
 
@@ -1761,7 +1764,7 @@ Target_x86_64::Relocate::tls_gd_to_ie(const Relocate_info<64, false>* relinfo,
                                       unsigned int,
                                       elfcpp::Elf_types<64>::Elf_Addr value,
                                       unsigned char* view,
-                                      off_t view_size)
+                                      section_size_type view_size)
 {
   // .byte 0x66; leaq foo@tlsgd(%rip),%rdi;
   // .word 0x6666; rex64; call __tls_get_addr
@@ -1796,7 +1799,7 @@ Target_x86_64::Relocate::tls_gd_to_le(const Relocate_info<64, false>* relinfo,
                                       unsigned int,
                                       elfcpp::Elf_types<64>::Elf_Addr value,
                                       unsigned char* view,
-                                      off_t view_size)
+                                      section_size_type view_size)
 {
   // .byte 0x66; leaq foo@tlsgd(%rip),%rdi;
   // .word 0x6666; rex64; call __tls_get_addr
@@ -1828,7 +1831,7 @@ Target_x86_64::Relocate::tls_ld_to_le(const Relocate_info<64, false>* relinfo,
                                       unsigned int,
                                       elfcpp::Elf_types<64>::Elf_Addr,
                                       unsigned char* view,
-                                      off_t view_size)
+                                      section_size_type view_size)
 {
   // leaq foo@tlsld(%rip),%rdi; call __tls_get_addr@plt;
   // ... leq foo@dtpoff(%rax),%reg
@@ -1860,7 +1863,7 @@ Target_x86_64::Relocate::tls_ie_to_le(const Relocate_info<64, false>* relinfo,
                                       unsigned int,
                                       elfcpp::Elf_types<64>::Elf_Addr value,
                                       unsigned char* view,
-                                      off_t view_size)
+                                      section_size_type view_size)
 {
   // We need to examine the opcodes to figure out which instruction we
   // are looking at.
@@ -1916,7 +1919,7 @@ Target_x86_64::relocate_section(const Relocate_info<64, false>* relinfo,
                                bool needs_special_offset_handling,
                                 unsigned char* view,
                                 elfcpp::Elf_types<64>::Elf_Addr address,
-                                off_t view_size)
+                                section_size_type view_size)
 {
   gold_assert(sh_type == elfcpp::SHT_RELA);
 
@@ -1949,7 +1952,7 @@ Target_x86_64::do_dynsym_value(const Symbol* gsym) const
 // the specified length.
 
 std::string
-Target_x86_64::do_code_fill(off_t length)
+Target_x86_64::do_code_fill(section_size_type length)
 {
   if (length >= 16)
     {