// 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;
}
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"),
// 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)
// 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;
// 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
// 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*
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
{ 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);
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.
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
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
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
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
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.
++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
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);
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);
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);
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_)
{
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();
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
{
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.
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
{
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.
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
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
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);
// 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)
{
// 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:
}
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)
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());
#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
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*
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;
{
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)
{
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"),
// 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
// 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.
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)
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;
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"));
}
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
{ 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);
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.
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
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
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
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
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.
++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
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);
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);
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);
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_)
{
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();
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
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
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
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.
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);
// 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)
{