This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch][gold] Avoid invalid unaligned write
- From: Rafael EspÃndola <rafael dot espindola at gmail dot com>
- To: Cary Coutant <ccoutant at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 15 Jun 2015 14:59:41 -0400
- Subject: Re: [patch][gold] Avoid invalid unaligned write
- Authentication-results: sourceware.org; auth=none
- References: <CAG3jReLrv-31r3M-LseE9HMo1AN9jJOcZH1HSZhuQAsSsiUjrA at mail dot gmail dot com> <CAJimCsHuUD2k_MJF+dbdPp9R8F2F-2sXV1+A1Z-9AKGhnzJXZw at mail dot gmail dot com> <CAG3jReLiDs2xhPyUbU4ibWKD4ObVQjQO1wGjH6cf-Jx8NopHwQ at mail dot gmail dot com>
> BTW, is there an architecture where it is known that the
> malloc+memcpy+aligned access is faster than doing unaligned accesses?
> I tested X86 and power8le and both got faster with unaligned. I can
> try on ARM when I get back home on Monday.
I just tested it (patch attached). The results I got were
x86:
master: 1.325797007s ( +- 0.00% )
unaligned: 1.197201064s ( +- 0.00% )
tegra tk1 (arm)
master: 5.619536031s ( +- 0.05% )
unaligned: 5.650522742s ( +- 0.05% )
gcc112 (power8 LE) (no root, so lower priority):
master: 2.715273952s ( +- 0.26% )
unaligned: 2.600145948s ( +- 0.81% )
gcc110 (power7 BE) (no root, no tmpfs, using 30 call to time instead of perf):
5.85267s
5.47700s
So the only case with a small slowdown was the tegra.
Cheers,
Rafael
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 722984e..1c60e01 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -36,6 +36,7 @@
#include "elfcpp_swap.h"
+#include <stddef.h>
#include <stdint.h>
namespace elfcpp
@@ -1027,6 +1028,16 @@ struct Elf_sizes
// Accessor class for the ELF file header.
+#define UNALIGNED_READ(RT, M) \
+ { \
+ typedef RT R_type; \
+ const R_type *p = reinterpret_cast<const R_type *>( \
+ reinterpret_cast<const char *>(this->p_) + offsetof(P_type, M)); \
+ R_type t; \
+ memcpy(&t, p, sizeof(t)); \
+ return Convert<sizeof(t)*8, big_endian>::convert_host(t); \
+ }
+
template<int size, bool big_endian>
class Ehdr
{
@@ -1043,15 +1054,19 @@ class Ehdr
const unsigned char*
get_e_ident() const
- { return this->p_->e_ident; }
+ {
+ const unsigned char *p = reinterpret_cast<const unsigned char *>(this->p_) +
+ offsetof(P_type, e_ident);
+ return p;
+ }
Elf_Half
get_e_type() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_type); }
+ { UNALIGNED_READ(Elf_Half, e_type); }
Elf_Half
get_e_machine() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_machine); }
+ { UNALIGNED_READ(Elf_Half, e_machine); }
Elf_Word
get_e_version() const
@@ -1067,7 +1082,7 @@ class Ehdr
typename Elf_types<size>::Elf_Off
get_e_shoff() const
- { return Convert<size, big_endian>::convert_host(this->p_->e_shoff); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Off, e_shoff); }
Elf_Word
get_e_flags() const
@@ -1075,7 +1090,7 @@ class Ehdr
Elf_Half
get_e_ehsize() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_ehsize); }
+ { UNALIGNED_READ(Elf_Half, e_ehsize); }
Elf_Half
get_e_phentsize() const
@@ -1087,18 +1102,19 @@ class Ehdr
Elf_Half
get_e_shentsize() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_shentsize); }
+ { UNALIGNED_READ(Elf_Half, e_shentsize); }
Elf_Half
get_e_shnum() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_shnum); }
+ { UNALIGNED_READ(Elf_Half, e_shnum); }
Elf_Half
get_e_shstrndx() const
- { return Convert<16, big_endian>::convert_host(this->p_->e_shstrndx); }
+ { UNALIGNED_READ(Elf_Half, e_shstrndx); }
private:
- const internal::Ehdr_data<size>* p_;
+ typedef internal::Ehdr_data<size> P_type;
+ const P_type* p_;
};
// Write class for the ELF file header.
@@ -1189,15 +1205,15 @@ class Shdr
Elf_Word
get_sh_name() const
- { return Convert<32, big_endian>::convert_host(this->p_->sh_name); }
+ { UNALIGNED_READ(Elf_Word, sh_name); }
Elf_Word
get_sh_type() const
- { return Convert<32, big_endian>::convert_host(this->p_->sh_type); }
+ { UNALIGNED_READ(Elf_Word, sh_type); }
typename Elf_types<size>::Elf_WXword
get_sh_flags() const
- { return Convert<size, big_endian>::convert_host(this->p_->sh_flags); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, sh_flags); }
typename Elf_types<size>::Elf_Addr
get_sh_addr() const
@@ -1205,19 +1221,19 @@ class Shdr
typename Elf_types<size>::Elf_Off
get_sh_offset() const
- { return Convert<size, big_endian>::convert_host(this->p_->sh_offset); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Off, sh_offset); }
typename Elf_types<size>::Elf_WXword
get_sh_size() const
- { return Convert<size, big_endian>::convert_host(this->p_->sh_size); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, sh_size); }
Elf_Word
get_sh_link() const
- { return Convert<32, big_endian>::convert_host(this->p_->sh_link); }
+ { UNALIGNED_READ(Elf_Word, sh_link); }
Elf_Word
get_sh_info() const
- { return Convert<32, big_endian>::convert_host(this->p_->sh_info); }
+ { UNALIGNED_READ(Elf_Word, sh_info); }
typename Elf_types<size>::Elf_WXword
get_sh_addralign() const
@@ -1226,10 +1242,11 @@ class Shdr
typename Elf_types<size>::Elf_WXword
get_sh_entsize() const
- { return Convert<size, big_endian>::convert_host(this->p_->sh_entsize); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, sh_entsize); }
private:
- const internal::Shdr_data<size>* p_;
+ typedef internal::Shdr_data<size> P_type;
+ const P_type* p_;
};
// Write class for an ELF section header.
@@ -1461,19 +1478,23 @@ class Sym
Elf_Word
get_st_name() const
- { return Convert<32, big_endian>::convert_host(this->p_->st_name); }
+ { UNALIGNED_READ(Elf_Word, st_name); }
typename Elf_types<size>::Elf_Addr
get_st_value() const
- { return Convert<size, big_endian>::convert_host(this->p_->st_value); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Addr, st_value); }
typename Elf_types<size>::Elf_WXword
get_st_size() const
- { return Convert<size, big_endian>::convert_host(this->p_->st_size); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, st_size); }
unsigned char
get_st_info() const
- { return this->p_->st_info; }
+ {
+ const unsigned char *p = reinterpret_cast<const unsigned char *>(this->p_) +
+ offsetof(P_type, st_info);
+ return *p;
+ }
STB
get_st_bind() const
@@ -1485,7 +1506,11 @@ class Sym
unsigned char
get_st_other() const
- { return this->p_->st_other; }
+ {
+ const unsigned char *p = reinterpret_cast<const unsigned char *>(this->p_) +
+ offsetof(P_type, st_other);
+ return *p;
+ }
STV
get_st_visibility() const
@@ -1497,10 +1522,11 @@ class Sym
Elf_Half
get_st_shndx() const
- { return Convert<16, big_endian>::convert_host(this->p_->st_shndx); }
+ { UNALIGNED_READ(Elf_Half, st_shndx); }
private:
- const internal::Sym_data<size>* p_;
+ typedef internal::Sym_data<size> P_type;
+ const P_type* p_;
};
// Writer class for an ELF symbol table entry.
@@ -1571,14 +1597,15 @@ class Rel
typename Elf_types<size>::Elf_Addr
get_r_offset() const
- { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Addr, r_offset); }
typename Elf_types<size>::Elf_WXword
get_r_info() const
- { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, r_info); }
private:
- const internal::Rel_data<size>* p_;
+ typedef internal::Rel_data<size> P_type;
+ const P_type* p_;
};
// Writer class for an ELF Rel relocation.
@@ -1621,18 +1648,19 @@ class Rela
typename Elf_types<size>::Elf_Addr
get_r_offset() const
- { return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Addr, r_offset); }
typename Elf_types<size>::Elf_WXword
get_r_info() const
- { return Convert<size, big_endian>::convert_host(this->p_->r_info); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_WXword, r_info); }
typename Elf_types<size>::Elf_Swxword
get_r_addend() const
- { return Convert<size, big_endian>::convert_host(this->p_->r_addend); }
+ { UNALIGNED_READ(typename Elf_types<size>::Elf_Swxword, r_addend); }
private:
- const internal::Rela_data<size>* p_;
+ typedef internal::Rela_data<size> P_type;
+ const P_type* p_;
};
// Writer class for an ELF Rela relocation.
diff --git a/elfcpp/elfcpp_swap.h b/elfcpp/elfcpp_swap.h
index 5b9a915..32c64f6 100644
--- a/elfcpp/elfcpp_swap.h
+++ b/elfcpp/elfcpp_swap.h
@@ -37,6 +37,7 @@
#define ELFCPP_SWAP_H
#include <stdint.h>
+#include <memory.h>
// We need an autoconf-generated config.h file for endianness and
// swapping. We check two macros: WORDS_BIGENDIAN and
@@ -230,11 +231,18 @@ struct Swap
static inline Valtype
readval(const Valtype* wv)
- { return Convert<size, big_endian>::convert_host(*wv); }
+ {
+ Valtype t;
+ memcpy(&t, wv, sizeof(t));
+ return Convert<size, big_endian>::convert_host(t);
+ }
static inline void
writeval(Valtype* wv, Valtype v)
- { *wv = Convert<size, big_endian>::convert_host(v); }
+ {
+ Valtype t = Convert<size, big_endian>::convert_host(v);
+ memcpy(wv, &t, sizeof(v));
+ }
static inline Valtype
readval(const unsigned char* wv)
@@ -263,238 +271,6 @@ struct Swap<8, big_endian>
{ *wv = v; }
};
-// Swap_unaligned is a template based on size and on whether the
-// target is big endian. It defines the type Valtype and the
-// functions readval and writeval. The functions read and write
-// values of the appropriate size out of buffers which may be
-// misaligned.
-
-template<int size, bool big_endian>
-struct Swap_unaligned;
-
-template<bool big_endian>
-struct Swap_unaligned<8, big_endian>
-{
- typedef typename Valtype_base<8>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- { return *wv; }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- { *wv = v; }
-};
-
-template<>
-struct Swap_unaligned<16, false>
-{
- typedef Valtype_base<16>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return (wv[1] << 8) | wv[0];
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[1] = v >> 8;
- wv[0] = v;
- }
-};
-
-template<>
-struct Swap_unaligned<16, true>
-{
- typedef Valtype_base<16>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return (wv[0] << 8) | wv[1];
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[0] = v >> 8;
- wv[1] = v;
- }
-};
-
-template<>
-struct Swap_unaligned<32, false>
-{
- typedef Valtype_base<32>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return (wv[3] << 24) | (wv[2] << 16) | (wv[1] << 8) | wv[0];
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[3] = v >> 24;
- wv[2] = v >> 16;
- wv[1] = v >> 8;
- wv[0] = v;
- }
-};
-
-template<>
-struct Swap_unaligned<32, true>
-{
- typedef Valtype_base<32>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return (wv[0] << 24) | (wv[1] << 16) | (wv[2] << 8) | wv[3];
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[0] = v >> 24;
- wv[1] = v >> 16;
- wv[2] = v >> 8;
- wv[3] = v;
- }
-};
-
-template<>
-struct Swap_unaligned<64, false>
-{
- typedef Valtype_base<64>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return ((static_cast<Valtype>(wv[7]) << 56)
- | (static_cast<Valtype>(wv[6]) << 48)
- | (static_cast<Valtype>(wv[5]) << 40)
- | (static_cast<Valtype>(wv[4]) << 32)
- | (static_cast<Valtype>(wv[3]) << 24)
- | (static_cast<Valtype>(wv[2]) << 16)
- | (static_cast<Valtype>(wv[1]) << 8)
- | static_cast<Valtype>(wv[0]));
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[7] = v >> 56;
- wv[6] = v >> 48;
- wv[5] = v >> 40;
- wv[4] = v >> 32;
- wv[3] = v >> 24;
- wv[2] = v >> 16;
- wv[1] = v >> 8;
- wv[0] = v;
- }
-};
-
-template<>
-struct Swap_unaligned<64, true>
-{
- typedef Valtype_base<64>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return ((static_cast<Valtype>(wv[0]) << 56)
- | (static_cast<Valtype>(wv[1]) << 48)
- | (static_cast<Valtype>(wv[2]) << 40)
- | (static_cast<Valtype>(wv[3]) << 32)
- | (static_cast<Valtype>(wv[4]) << 24)
- | (static_cast<Valtype>(wv[5]) << 16)
- | (static_cast<Valtype>(wv[6]) << 8)
- | static_cast<Valtype>(wv[7]));
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- wv[0] = v >> 56;
- wv[1] = v >> 48;
- wv[2] = v >> 40;
- wv[3] = v >> 32;
- wv[4] = v >> 24;
- wv[5] = v >> 16;
- wv[6] = v >> 8;
- wv[7] = v;
- }
-};
-
-// Swap_aligned32 is a template based on size and on whether the
-// target is big endian. It defines the type Valtype and the
-// functions readval and writeval. The functions read and write
-// values of the appropriate size out of buffers which may not be
-// 64-bit aligned, but are 32-bit aligned.
-
-template<int size, bool big_endian>
-struct Swap_aligned32
-{
- typedef typename Valtype_base<size>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- { return Swap<size, big_endian>::readval(
- reinterpret_cast<const Valtype*>(wv)); }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- { Swap<size, big_endian>::writeval(reinterpret_cast<Valtype*>(wv), v); }
-};
-
-template<>
-struct Swap_aligned32<64, true>
-{
- typedef Valtype_base<64>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return ((static_cast<Valtype>(Swap<32, true>::readval(wv)) << 32)
- | static_cast<Valtype>(Swap<32, true>::readval(wv + 4)));
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- typedef Valtype_base<32>::Valtype Valtype32;
-
- Swap<32, true>::writeval(wv, static_cast<Valtype32>(v >> 32));
- Swap<32, true>::writeval(wv + 4, static_cast<Valtype32>(v));
- }
-};
-
-template<>
-struct Swap_aligned32<64, false>
-{
- typedef Valtype_base<64>::Valtype Valtype;
-
- static inline Valtype
- readval(const unsigned char* wv)
- {
- return ((static_cast<Valtype>(Swap<32, false>::readval(wv + 4)) << 32)
- | static_cast<Valtype>(Swap<32, false>::readval(wv)));
- }
-
- static inline void
- writeval(unsigned char* wv, Valtype v)
- {
- typedef Valtype_base<32>::Valtype Valtype32;
-
- Swap<32, false>::writeval(wv + 4, static_cast<Valtype32>(v >> 32));
- Swap<32, false>::writeval(wv, static_cast<Valtype32>(v));
- }
-};
-
} // End namespace elfcpp.
#endif // !defined(ELFCPP_SWAP_H)
diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index 72a65db..a3e1053 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -1758,7 +1758,7 @@ AArch64_relobj<size, big_endian>::do_count_local_symbols(
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// For mapping symbol processing, we need to read the symbol names.
unsigned int strtab_shndx = this->adjust_shndx(symtabshdr.get_sh_link());
@@ -1780,7 +1780,7 @@ AArch64_relobj<size, big_endian>::do_count_local_symbols(
const char* pnames =
reinterpret_cast<const char*>(this->get_view(strtabshdr.get_sh_offset(),
strtabshdr.get_sh_size(),
- false, false));
+ false));
// Skip the first dummy symbol.
psyms += sym_size;
@@ -2086,8 +2086,7 @@ AArch64_relobj<size, big_endian>::scan_sections_for_stubs(
// Read the section headers.
const unsigned char* pshdrs = this->get_view(this->elf_file()->shoff(),
- shnum * shdr_size,
- true, true);
+ shnum * shdr_size, true);
// To speed up processing, we set up hash tables for fast lookup of
// input offsets to output addresses.
@@ -2131,7 +2130,7 @@ AArch64_relobj<size, big_endian>::scan_sections_for_stubs(
// Get the relocations.
const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
shdr.get_sh_size(),
- true, false);
+ false);
// Get the section contents.
section_size_type input_view_size = 0;
@@ -4964,11 +4963,11 @@ class AArch64_relocate_functions
AArch64_valtype addend,
const AArch64_reloc_property* reloc_property)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
typename elfcpp::Elf_types<size>::Elf_Addr x =
psymval->value(object, addend);
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view,
+ elfcpp::Swap<valsize, big_endian>::writeval(view,
static_cast<Valtype>(x));
return (reloc_property->checkup_x_value(x)
? This::STATUS_OKAY
@@ -4986,10 +4985,10 @@ class AArch64_relocate_functions
Address address,
const AArch64_reloc_property* reloc_property)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
Address x = psymval->value(object, addend) - address;
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view,
+ elfcpp::Swap<valsize, big_endian>::writeval(view,
static_cast<Valtype>(x));
return (reloc_property->checkup_x_value(x)
? This::STATUS_OKAY
diff --git a/gold/archive.cc b/gold/archive.cc
index 6d25980..12a58d4 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -242,7 +242,7 @@ Archive::setup()
if (xname == "/")
{
const unsigned char* p = this->get_view(off + sizeof(Archive_header),
- extended_size, false, true);
+ extended_size, true);
const char* px = reinterpret_cast<const char*>(p);
this->extended_names_.assign(px, extended_size);
}
@@ -283,7 +283,7 @@ Archive::read_armap(off_t start, section_size_type size)
off_t last_seen_offset = -1;
// Read in the entire armap.
- const unsigned char* p = this->get_view(start, size, true, false);
+ const unsigned char* p = this->get_view(start, size, false);
// Numbers in the armap are always big-endian.
const elfcpp::Elf_Word* pword = reinterpret_cast<const elfcpp::Elf_Word*>(p);
@@ -329,8 +329,7 @@ off_t
Archive::read_header(off_t off, bool cache, std::string* pname,
off_t* nested_off)
{
- const unsigned char* p = this->get_view(off, sizeof(Archive_header), true,
- cache);
+ const unsigned char* p = this->get_view(off, sizeof(Archive_header), cache);
const Archive_header* hdr = reinterpret_cast<const Archive_header*>(p);
return this->interpret_header(hdr, off, pname, nested_off);
}
diff --git a/gold/archive.h b/gold/archive.h
index 18cd899..77a2e71 100644
--- a/gold/archive.h
+++ b/gold/archive.h
@@ -286,8 +286,8 @@ class Archive : public Library_base
// Get a view into the underlying file.
const unsigned char*
- get_view(off_t start, section_size_type size, bool aligned, bool cache)
- { return this->input_file_->file().get_view(0, start, size, aligned, cache); }
+ get_view(off_t start, section_size_type size, bool cache)
+ { return this->input_file_->file().get_view(0, start, size, cache); }
// Read the archive symbol map.
void
diff --git a/gold/arm.cc b/gold/arm.cc
index 9812c88..6725226 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -3312,12 +3312,12 @@ class Arm_relocate_functions : public Relocate_functions<32, big_endian>
const Sized_relobj_file<32, big_endian>* object,
const Symbol_value<32>* psymval)
{
- typedef typename elfcpp::Swap_unaligned<16, big_endian>::Valtype Valtype;
- Valtype val = elfcpp::Swap_unaligned<16, big_endian>::readval(view);
+ typedef typename elfcpp::Swap<16, big_endian>::Valtype Valtype;
+ Valtype val = elfcpp::Swap<16, big_endian>::readval(view);
int32_t addend = Bits<16>::sign_extend32(val);
Arm_address x = psymval->value(object, addend);
val = Bits<32>::bit_select32(val, x, 0xffffU);
- elfcpp::Swap_unaligned<16, big_endian>::writeval(view, val);
+ elfcpp::Swap<16, big_endian>::writeval(view, val);
// R_ARM_ABS16 permits signed or unsigned results.
return (Bits<16>::has_signed_unsigned_overflow32(x)
@@ -3332,10 +3332,10 @@ class Arm_relocate_functions : public Relocate_functions<32, big_endian>
const Symbol_value<32>* psymval,
Arm_address thumb_bit)
{
- typedef typename elfcpp::Swap_unaligned<32, big_endian>::Valtype Valtype;
- Valtype addend = elfcpp::Swap_unaligned<32, big_endian>::readval(view);
+ typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype;
+ Valtype addend = elfcpp::Swap<32, big_endian>::readval(view);
Valtype x = psymval->value(object, addend) | thumb_bit;
- elfcpp::Swap_unaligned<32, big_endian>::writeval(view, x);
+ elfcpp::Swap<32, big_endian>::writeval(view, x);
return This::STATUS_OKAY;
}
@@ -3347,10 +3347,10 @@ class Arm_relocate_functions : public Relocate_functions<32, big_endian>
Arm_address address,
Arm_address thumb_bit)
{
- typedef typename elfcpp::Swap_unaligned<32, big_endian>::Valtype Valtype;
- Valtype addend = elfcpp::Swap_unaligned<32, big_endian>::readval(view);
+ typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype;
+ Valtype addend = elfcpp::Swap<32, big_endian>::readval(view);
Valtype x = (psymval->value(object, addend) | thumb_bit) - address;
- elfcpp::Swap_unaligned<32, big_endian>::writeval(view, x);
+ elfcpp::Swap<32, big_endian>::writeval(view, x);
return This::STATUS_OKAY;
}
@@ -3468,12 +3468,12 @@ class Arm_relocate_functions : public Relocate_functions<32, big_endian>
Arm_address address,
Arm_address thumb_bit)
{
- typedef typename elfcpp::Swap_unaligned<32, big_endian>::Valtype Valtype;
- Valtype val = elfcpp::Swap_unaligned<32, big_endian>::readval(view);
+ typedef typename elfcpp::Swap<32, big_endian>::Valtype Valtype;
+ Valtype val = elfcpp::Swap<32, big_endian>::readval(view);
Valtype addend = Bits<31>::sign_extend32(val);
Valtype x = (psymval->value(object, addend) | thumb_bit) - address;
val = Bits<32>::bit_select32(val, x, 0x7fffffffU);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(view, val);
+ elfcpp::Swap<32, big_endian>::writeval(view, val);
return (Bits<31>::has_overflow32(x)
? This::STATUS_OVERFLOW
: This::STATUS_OKAY);
@@ -5345,9 +5345,9 @@ Arm_exidx_cantunwind::do_fixed_endian_write(Output_file* of)
uint32_t prel31_offset = output_address - this->address();
if (Bits<31>::has_overflow32(offset))
gold_error(_("PREL31 overflow in EXIDX_CANTUNWIND entry"));
- elfcpp::Swap_unaligned<32, big_endian>::writeval(oview,
+ elfcpp::Swap<32, big_endian>::writeval(oview,
prel31_offset & 0x7fffffffU);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(oview + 4,
+ elfcpp::Swap<32, big_endian>::writeval(oview + 4,
elfcpp::EXIDX_CANTUNWIND);
of->write_output_view(this->offset(), oview_size, oview);
@@ -6327,7 +6327,7 @@ Arm_relobj<big_endian>::scan_sections_for_stubs(
// Read the section headers.
const unsigned char* pshdrs = this->get_view(this->elf_file()->shoff(),
shnum * shdr_size,
- true, true);
+ true);
// To speed up processing, we set up hash tables for fast lookup of
// input offsets to output addresses.
@@ -6365,7 +6365,7 @@ Arm_relobj<big_endian>::scan_sections_for_stubs(
// Get the relocations.
const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
shdr.get_sh_size(),
- true, false);
+ false);
// Get the section contents. This does work for the case in which
// we modify the contents of an input section. We need to pass the
@@ -6456,7 +6456,7 @@ Arm_relobj<big_endian>::do_count_local_symbols(
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// For mapping symbol processing, we need to read the symbol names.
unsigned int strtab_shndx = this->adjust_shndx(symtabshdr.get_sh_link());
@@ -6477,7 +6477,7 @@ Arm_relobj<big_endian>::do_count_local_symbols(
const char* pnames =
reinterpret_cast<const char*>(this->get_view(strtabshdr.get_sh_offset(),
strtabshdr.get_sh_size(),
- false, false));
+ false));
// Loop over the local symbols and mark any local symbols pointing
// to THUMB functions.
@@ -6648,7 +6648,7 @@ Arm_relobj<big_endian>::find_linked_text_section(
// Get the relocations.
const unsigned char* prelocs =
- this->get_view(shdr.get_sh_offset(), shdr.get_sh_size(), true, false);
+ this->get_view(shdr.get_sh_offset(), shdr.get_sh_size(), false);
// Find the REL31 relocation for the first word of the first EXIDX entry.
for (size_t i = 0; i < reloc_count; ++i, prelocs += reloc_size)
@@ -6782,7 +6782,7 @@ Arm_relobj<big_endian>::do_read_symbols(Read_symbols_data* sd)
// Read processor-specific flags in ELF file header.
const unsigned char* pehdr = this->get_view(elfcpp::file_header_offset,
elfcpp::Elf_sizes<32>::ehdr_size,
- true, false);
+ false);
elfcpp::Ehdr<32, big_endian> ehdr(pehdr);
this->processor_specific_flags_ = ehdr.get_e_flags();
@@ -6820,7 +6820,7 @@ Arm_relobj<big_endian>::do_read_symbols(Read_symbols_data* sd)
section_size_type section_size =
convert_to_section_size_type(shdr.get_sh_size());
const unsigned char* view =
- this->get_view(section_offset, section_size, true, false);
+ this->get_view(section_offset, section_size, false);
this->attributes_section_data_ =
new Attributes_section_data(view, section_size);
}
@@ -6894,7 +6894,7 @@ Arm_relobj<big_endian>::do_read_symbols(Read_symbols_data* sd)
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// Process the deferred EXIDX sections.
for (unsigned int i = 0; i < deferred_exidx_sections.size(); ++i)
@@ -6938,7 +6938,7 @@ Arm_relobj<big_endian>::do_gc_process_relocs(Symbol_table* symtab,
const unsigned int shdr_size = elfcpp::Elf_sizes<32>::shdr_size;
const unsigned char* pshdrs = this->get_view(this->elf_file()->shoff(),
shnum * shdr_size,
- true, true);
+ true);
// Scan section headers for sections of type SHT_ARM_EXIDX. Add references
// to these from the linked text sections.
@@ -6988,7 +6988,7 @@ Arm_relobj<big_endian>::update_output_local_symbol_count()
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// Loop over the local symbols.
@@ -7063,7 +7063,7 @@ Arm_dynobj<big_endian>::do_read_symbols(Read_symbols_data* sd)
// Read processor-specific flags in ELF file header.
const unsigned char* pehdr = this->get_view(elfcpp::file_header_offset,
elfcpp::Elf_sizes<32>::ehdr_size,
- true, false);
+ false);
elfcpp::Ehdr<32, big_endian> ehdr(pehdr);
this->processor_specific_flags_ = ehdr.get_e_flags();
@@ -7082,7 +7082,7 @@ Arm_dynobj<big_endian>::do_read_symbols(Read_symbols_data* sd)
section_size_type section_size =
convert_to_section_size_type(shdr.get_sh_size());
const unsigned char* view =
- this->get_view(section_offset, section_size, true, false);
+ this->get_view(section_offset, section_size,false);
this->attributes_section_data_ =
new Attributes_section_data(view, section_size);
break;
diff --git a/gold/binary.cc b/gold/binary.cc
index 12ca296..18afc67 100644
--- a/gold/binary.cc
+++ b/gold/binary.cc
@@ -136,7 +136,7 @@ Binary_to_elf::sized_convert(const Task* task)
if (filesize == 0)
fileview = NULL;
else
- fileview = f.get_view(0, 0, filesize, false, false);
+ fileview = f.get_view(0, 0, filesize, false);
unsigned int align;
if (size == 32)
diff --git a/gold/compressed_output.cc b/gold/compressed_output.cc
index 8c9fc1e..bcd3531 100644
--- a/gold/compressed_output.cc
+++ b/gold/compressed_output.cc
@@ -62,7 +62,7 @@ zlib_compress(const unsigned char* uncompressed_data,
if (rc == Z_OK)
{
memcpy(*compressed_data, "ZLIB", 4);
- elfcpp::Swap_unaligned<64, true>::writeval(*compressed_data + 4,
+ elfcpp::Swap<64, true>::writeval(*compressed_data + 4,
uncompressed_size);
*compressed_size += header_size;
return true;
@@ -133,7 +133,7 @@ get_uncompressed_size(const unsigned char* compressed_data,
if (compressed_size >= zlib_header_size
&& strncmp(reinterpret_cast<const char*>(compressed_data),
"ZLIB", 4) == 0)
- return elfcpp::Swap_unaligned<64, true>::readval(compressed_data + 4);
+ return elfcpp::Swap<64, true>::readval(compressed_data + 4);
return -1ULL;
}
@@ -155,7 +155,7 @@ decompress_input_section(const unsigned char* compressed_data,
"ZLIB", 4) == 0)
{
unsigned long uncompressed_size_check =
- elfcpp::Swap_unaligned<64, true>::readval(compressed_data + 4);
+ elfcpp::Swap<64, true>::readval(compressed_data + 4);
gold_assert(uncompressed_size_check == uncompressed_size);
return zlib_decompress(compressed_data + zlib_header_size,
compressed_size - zlib_header_size,
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index 59b85b8..f219f63 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -1274,13 +1274,13 @@ Dwarf_info_reader::do_parse()
if (!this->check_buffer(pinfo + 4))
break;
uint32_t unit_length =
- elfcpp::Swap_unaligned<32, big_endian>::readval(pinfo);
+ elfcpp::Swap<32, big_endian>::readval(pinfo);
pinfo += 4;
if (unit_length == 0xffffffff)
{
if (!this->check_buffer(pinfo + 8))
break;
- unit_length = elfcpp::Swap_unaligned<64, big_endian>::readval(pinfo);
+ unit_length = elfcpp::Swap<64, big_endian>::readval(pinfo);
pinfo += 8;
this->offset_size_ = 8;
}
@@ -1295,14 +1295,14 @@ Dwarf_info_reader::do_parse()
// Read version (2 bytes).
this->cu_version_ =
- elfcpp::Swap_unaligned<16, big_endian>::readval(pinfo);
+ elfcpp::Swap<16, big_endian>::readval(pinfo);
pinfo += 2;
// Read debug_abbrev_offset (4 or 8 bytes).
if (this->offset_size_ == 4)
- abbrev_offset = elfcpp::Swap_unaligned<32, big_endian>::readval(pinfo);
+ abbrev_offset = elfcpp::Swap<32, big_endian>::readval(pinfo);
else
- abbrev_offset = elfcpp::Swap_unaligned<64, big_endian>::readval(pinfo);
+ abbrev_offset = elfcpp::Swap<64, big_endian>::readval(pinfo);
if (this->reloc_shndx_ > 0)
{
off_t reloc_offset = pinfo - this->buffer_;
@@ -1330,16 +1330,16 @@ Dwarf_info_reader::do_parse()
break;
// Read type_signature (8 bytes).
- signature = elfcpp::Swap_unaligned<64, big_endian>::readval(pinfo);
+ signature = elfcpp::Swap<64, big_endian>::readval(pinfo);
pinfo += 8;
// Read type_offset (4 or 8 bytes).
if (this->offset_size_ == 4)
type_offset =
- elfcpp::Swap_unaligned<32, big_endian>::readval(pinfo);
+ elfcpp::Swap<32, big_endian>::readval(pinfo);
else
type_offset =
- elfcpp::Swap_unaligned<64, big_endian>::readval(pinfo);
+ elfcpp::Swap<64, big_endian>::readval(pinfo);
pinfo += this->offset_size_;
}
@@ -1425,9 +1425,9 @@ Dwarf_info_reader::read_from_pointer(const unsigned char* source)
{
typename elfcpp::Valtype_base<valsize>::Valtype return_value;
if (this->object_->is_big_endian())
- return_value = elfcpp::Swap_unaligned<valsize, true>::readval(source);
+ return_value = elfcpp::Swap<valsize, true>::readval(source);
else
- return_value = elfcpp::Swap_unaligned<valsize, false>::readval(source);
+ return_value = elfcpp::Swap<valsize, false>::readval(source);
return return_value;
}
@@ -1438,9 +1438,9 @@ Dwarf_info_reader::read_from_pointer(const unsigned char** source)
{
typename elfcpp::Valtype_base<valsize>::Valtype return_value;
if (this->object_->is_big_endian())
- return_value = elfcpp::Swap_unaligned<valsize, true>::readval(*source);
+ return_value = elfcpp::Swap<valsize, true>::readval(*source);
else
- return_value = elfcpp::Swap_unaligned<valsize, false>::readval(*source);
+ return_value = elfcpp::Swap<valsize, false>::readval(*source);
*source += valsize / 8;
return return_value;
}
@@ -1622,7 +1622,7 @@ const unsigned char*
Sized_dwarf_line_info<size, big_endian>::read_header_prolog(
const unsigned char* lineptr)
{
- uint32_t initial_length = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr);
+ uint32_t initial_length = elfcpp::Swap<32, big_endian>::readval(lineptr);
lineptr += 4;
// In DWARF2/3, if the initial length is all 1 bits, then the offset
@@ -1630,7 +1630,7 @@ Sized_dwarf_line_info<size, big_endian>::read_header_prolog(
if (initial_length == 0xffffffff)
{
header_.offset_size = 8;
- initial_length = elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr);
+ initial_length = elfcpp::Swap<64, big_endian>::readval(lineptr);
lineptr += 8;
}
else
@@ -1640,13 +1640,13 @@ Sized_dwarf_line_info<size, big_endian>::read_header_prolog(
gold_assert(lineptr + header_.total_length <= buffer_end_);
- header_.version = elfcpp::Swap_unaligned<16, big_endian>::readval(lineptr);
+ header_.version = elfcpp::Swap<16, big_endian>::readval(lineptr);
lineptr += 2;
if (header_.offset_size == 4)
- header_.prologue_length = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr);
+ header_.prologue_length = elfcpp::Swap<32, big_endian>::readval(lineptr);
else
- header_.prologue_length = elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr);
+ header_.prologue_length = elfcpp::Swap<64, big_endian>::readval(lineptr);
lineptr += header_.offset_size;
header_.min_insn_length = *lineptr;
@@ -1827,7 +1827,7 @@ Sized_dwarf_line_info<size, big_endian>::process_one_opcode(
case elfcpp::DW_LNS_fixed_advance_pc:
{
int advance_address;
- advance_address = elfcpp::Swap_unaligned<16, big_endian>::readval(start);
+ advance_address = elfcpp::Swap<16, big_endian>::readval(start);
oplen += 2;
lsm->address += advance_address;
}
@@ -1866,7 +1866,7 @@ Sized_dwarf_line_info<size, big_endian>::process_one_opcode(
case elfcpp::DW_LNE_set_address:
{
lsm->address =
- elfcpp::Swap_unaligned<size, big_endian>::readval(start);
+ elfcpp::Swap<size, big_endian>::readval(start);
typename Reloc_map::const_iterator it
= this->reloc_map_.find(start - this->buffer_);
if (it != reloc_map_.end())
diff --git a/gold/dwp.cc b/gold/dwp.cc
index 16d471c..ef95295 100644
--- a/gold/dwp.cc
+++ b/gold/dwp.cc
@@ -782,7 +782,7 @@ Sized_relobj_dwo<size, big_endian>::setup()
// Read the section headers.
const unsigned char* const pshdrs = this->get_view(shoff, shnum * shdr_size,
- true, false);
+ false);
// Read the section names.
const unsigned char* pshdrnames =
@@ -794,8 +794,7 @@ Sized_relobj_dwo<size, big_endian>::setup()
section_size_type section_names_size =
convert_to_section_size_type(shdrnames.get_sh_size());
const unsigned char* namesu = this->get_view(shdrnames.get_sh_offset(),
- section_names_size, false,
- false);
+ section_names_size, false);
const char* names = reinterpret_cast<const char*>(namesu);
Compressed_section_map* compressed_sections =
@@ -821,7 +820,7 @@ Sized_relobj_dwo<size, big_endian>::do_section_contents(
static const unsigned char empty[1] = { '\0' };
return empty;
}
- return this->get_view(loc.file_offset, *plen, true, cache);
+ return this->get_view(loc.file_offset, *plen, cache);
}
// Class Dwo_file.
@@ -1040,7 +1039,7 @@ Dwo_file::make_object(Dwp_output_file* output_file)
if (filesize < hdrsize)
hdrsize = filesize;
const unsigned char* elf_header =
- input_file->file().get_view(0, 0, hdrsize, true, false);
+ input_file->file().get_view(0, 0, hdrsize, false);
if (!elfcpp::Elf_recognizer::is_elf_file(elf_header, hdrsize))
gold_fatal(_("%s: not an ELF object file"), this->name_);
@@ -1147,7 +1146,7 @@ Dwo_file::sized_read_unit_index(unsigned int shndx,
this->section_contents(shndx, &index_len, &index_is_new);
unsigned int version =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents);
+ elfcpp::Swap<32, big_endian>::readval(contents);
// We don't support version 1 anymore because it was experimental
// and because in normal use, dwp is not expected to read .dwp files
@@ -1157,10 +1156,10 @@ Dwo_file::sized_read_unit_index(unsigned int shndx,
this->name_, this->section_name(shndx).c_str(), version);
unsigned int ncols =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ sizeof(uint32_t));
unsigned int nused =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ 2 * sizeof(uint32_t));
if (ncols == 0 || nused == 0)
return;
@@ -1168,7 +1167,7 @@ Dwo_file::sized_read_unit_index(unsigned int shndx,
gold_assert(info_shndx > 0);
unsigned int nslots =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ 3 * sizeof(uint32_t));
const unsigned char* phash = contents + 4 * sizeof(uint32_t);
@@ -1201,9 +1200,9 @@ Dwo_file::sized_read_unit_index(unsigned int shndx,
for (unsigned int i = 0; i < nslots; ++i)
{
uint64_t signature =
- elfcpp::Swap_unaligned<64, big_endian>::readval(phash);
+ elfcpp::Swap<64, big_endian>::readval(phash);
unsigned int index =
- elfcpp::Swap_unaligned<32, big_endian>::readval(pindex);
+ elfcpp::Swap<32, big_endian>::readval(pindex);
if (index != 0 && (!is_tu_index || !output_file->lookup_tu(signature)))
{
Unit_set* unit_set = new Unit_set();
@@ -1219,11 +1218,11 @@ Dwo_file::sized_read_unit_index(unsigned int shndx,
for (unsigned int j = 0; j <= ncols; j++)
{
unsigned int dw_sect =
- elfcpp::Swap_unaligned<64, big_endian>::readval(pch);
+ elfcpp::Swap<64, big_endian>::readval(pch);
unsigned int offset =
- elfcpp::Swap_unaligned<64, big_endian>::readval(porow);
+ elfcpp::Swap<64, big_endian>::readval(porow);
unsigned int size =
- elfcpp::Swap_unaligned<64, big_endian>::readval(psrow);
+ elfcpp::Swap<64, big_endian>::readval(psrow);
unit_set->sections[dw_sect].offset = (sections[dw_sect].offset
+ offset);
unit_set->sections[dw_sect].size = size;
@@ -1289,7 +1288,7 @@ Dwo_file::sized_verify_dwo_list(unsigned int shndx, const File_list& files)
this->section_contents(shndx, &index_len, &index_is_new);
unsigned int version =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents);
+ elfcpp::Swap<32, big_endian>::readval(contents);
// We don't support version 1 anymore because it was experimental
// and because in normal use, dwp is not expected to read .dwp files
@@ -1299,16 +1298,16 @@ Dwo_file::sized_verify_dwo_list(unsigned int shndx, const File_list& files)
this->name_, this->section_name(shndx).c_str(), version);
unsigned int ncols =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ sizeof(uint32_t));
unsigned int nused =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ 2 * sizeof(uint32_t));
if (ncols == 0 || nused == 0)
return true;
unsigned int nslots =
- elfcpp::Swap_unaligned<32, big_endian>::readval(contents
+ elfcpp::Swap<32, big_endian>::readval(contents
+ 3 * sizeof(uint32_t));
const unsigned char* phash = contents + 4 * sizeof(uint32_t);
@@ -1329,8 +1328,8 @@ Dwo_file::sized_verify_dwo_list(unsigned int shndx, const File_list& files)
unsigned int slot = static_cast<unsigned int>(dwo_id) & (nslots - 1);
const unsigned char* ph = phash + slot * sizeof(uint64_t);
const unsigned char* pi = pindex + slot * sizeof(uint32_t);
- uint64_t probe = elfcpp::Swap_unaligned<64, big_endian>::readval(ph);
- uint32_t row_index = elfcpp::Swap_unaligned<32, big_endian>::readval(pi);
+ uint64_t probe = elfcpp::Swap<64, big_endian>::readval(ph);
+ uint32_t row_index = elfcpp::Swap<32, big_endian>::readval(pi);
if (row_index != 0 && probe != dwo_id)
{
unsigned int h2 = ((static_cast<unsigned int>(dwo_id >> 32)
@@ -1340,8 +1339,8 @@ Dwo_file::sized_verify_dwo_list(unsigned int shndx, const File_list& files)
slot = (slot + h2) & (nslots - 1);
ph = phash + slot * sizeof(uint64_t);
pi = pindex + slot * sizeof(uint32_t);
- probe = elfcpp::Swap_unaligned<64, big_endian>::readval(ph);
- row_index = elfcpp::Swap_unaligned<32, big_endian>::readval(pi);
+ probe = elfcpp::Swap<64, big_endian>::readval(ph);
+ row_index = elfcpp::Swap<32, big_endian>::readval(pi);
} while (row_index != 0 && probe != dwo_id);
}
if (row_index == 0)
@@ -1475,9 +1474,9 @@ Dwo_file::sized_remap_str_offsets(const unsigned char* contents,
unsigned char* q = remapped;
while (len > 0)
{
- unsigned int val = elfcpp::Swap_unaligned<32, big_endian>::readval(p);
+ unsigned int val = elfcpp::Swap<32, big_endian>::readval(p);
val = this->remap_str_offset(val);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(q, val);
+ elfcpp::Swap<32, big_endian>::writeval(q, val);
len -= 4;
p += 4;
q += 4;
@@ -1992,26 +1991,26 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index)
// Write the section header: version number, padding,
// number of used slots and total number of slots.
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, 2);
+ elfcpp::Swap<32, big_endian>::writeval(p, 2);
p += sizeof(uint32_t);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, ncols);
+ elfcpp::Swap<32, big_endian>::writeval(p, ncols);
p += sizeof(uint32_t);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, nused);
+ elfcpp::Swap<32, big_endian>::writeval(p, nused);
p += sizeof(uint32_t);
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, nslots);
+ elfcpp::Swap<32, big_endian>::writeval(p, nslots);
p += sizeof(uint32_t);
// Write the hash table.
for (unsigned int i = 0; i < nslots; ++i)
{
- elfcpp::Swap_unaligned<64, big_endian>::writeval(p, index.hash_table(i));
+ elfcpp::Swap<64, big_endian>::writeval(p, index.hash_table(i));
p += sizeof(uint64_t);
}
// Write the parallel index table.
for (unsigned int i = 0; i < nslots; ++i)
{
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, index.index_table(i));
+ elfcpp::Swap<32, big_endian>::writeval(p, index.index_table(i));
p += sizeof(uint32_t);
}
@@ -2020,7 +2019,7 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index)
{
if (column_mask & (1 << c))
{
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, c);
+ elfcpp::Swap<32, big_endian>::writeval(p, c);
p += sizeof(uint32_t);
}
}
@@ -2036,7 +2035,7 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index)
if (column_mask & (1 << c))
{
section_offset_type offset = sects[c].offset;
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, offset);
+ elfcpp::Swap<32, big_endian>::writeval(p, offset);
p += sizeof(uint32_t);
}
else
@@ -2056,7 +2055,7 @@ Dwp_output_file::write_index(const char* sect_name, const Dwp_index& index)
if (column_mask & (1 << c))
{
section_size_type size = sects[c].size;
- elfcpp::Swap_unaligned<32, big_endian>::writeval(p, size);
+ elfcpp::Swap<32, big_endian>::writeval(p, size);
p += sizeof(uint32_t);
}
else
diff --git a/gold/dynobj.cc b/gold/dynobj.cc
index 13e3f61..66f3ebc 100644
--- a/gold/dynobj.cc
+++ b/gold/dynobj.cc
@@ -232,7 +232,7 @@ Sized_dynobj<size, big_endian>::read_dynsym_section(
shndx, this->adjust_shndx(shdr.get_sh_link()), link);
*view = this->get_lasting_view(shdr.get_sh_offset(), shdr.get_sh_size(),
- true, false);
+ false);
*view_size = convert_to_section_size_type(shdr.get_sh_size());
*view_info = shdr.get_sh_info();
}
@@ -257,7 +257,7 @@ Sized_dynobj<size, big_endian>::read_dynamic(const unsigned char* pshdrs,
const off_t dynamic_size = dynamicshdr.get_sh_size();
const unsigned char* pdynamic = this->get_view(dynamicshdr.get_sh_offset(),
- dynamic_size, true, false);
+ dynamic_size, false);
const unsigned int link = this->adjust_shndx(dynamicshdr.get_sh_link());
if (link != strtab_shndx)
@@ -278,8 +278,7 @@ Sized_dynobj<size, big_endian>::read_dynamic(const unsigned char* pshdrs,
}
strtab_size = strtabshdr.get_sh_size();
- strtabu = this->get_view(strtabshdr.get_sh_offset(), strtab_size, false,
- false);
+ strtabu = this->get_view(strtabshdr.get_sh_offset(), strtab_size, false);
}
const char* const strtab = reinterpret_cast<const char*>(strtabu);
@@ -392,8 +391,7 @@ Sized_dynobj<size, big_endian>::base_read_symbols(Read_symbols_data* sd)
+ this->dynsym_shndx_ * This::shdr_size);
sd->symbols = this->get_lasting_view(dynsymshdr.get_sh_offset(),
- dynsymshdr.get_sh_size(), true,
- false);
+ dynsymshdr.get_sh_size(), false);
sd->symbols_size =
convert_to_section_size_type(dynsymshdr.get_sh_size());
@@ -416,7 +414,7 @@ Sized_dynobj<size, big_endian>::base_read_symbols(Read_symbols_data* sd)
sd->symbol_names = this->get_lasting_view(strtabshdr.get_sh_offset(),
strtabshdr.get_sh_size(),
- false, false);
+ false);
sd->symbol_names_size =
convert_to_section_size_type(strtabshdr.get_sh_size());
diff --git a/gold/dynobj.h b/gold/dynobj.h
index b7c60f8..4beff81 100644
--- a/gold/dynobj.h
+++ b/gold/dynobj.h
@@ -219,7 +219,7 @@ class Sized_dynobj : public Dynobj
static const unsigned char empty[1] = { '\0' };
return empty;
}
- return this->get_view(loc.file_offset, *plen, true, cache);
+ return this->get_view(loc.file_offset, *plen, cache);
}
// Return section flags.
diff --git a/gold/ehframe.cc b/gold/ehframe.cc
index 262766e..46d79a9 100644
--- a/gold/ehframe.cc
+++ b/gold/ehframe.cc
@@ -258,7 +258,7 @@ Eh_frame_hdr::get_fde_pc(
case elfcpp::DW_EH_PE_udata8:
gold_assert(size == 64);
- pc = elfcpp::Swap_unaligned<64, big_endian>::readval(p);
+ pc = elfcpp::Swap<64, big_endian>::readval(p);
break;
default:
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 0bd8320..293e189 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -328,21 +328,16 @@ File_read::is_locked() const
// not for the requested BYTESHIFT.
inline File_read::View*
-File_read::find_view(off_t start, section_size_type size,
- unsigned int byteshift, File_read::View** vshifted) const
+File_read::find_view(off_t start, section_size_type size) const
{
gold_assert(start <= this->size_
&& (static_cast<unsigned long long>(size)
<= static_cast<unsigned long long>(this->size_ - start)));
- if (vshifted != NULL)
- *vshifted = NULL;
-
// If we have the whole file mmapped, and the alignment is right,
// we can return it.
if (this->whole_file_view_)
- if (byteshift == -1U || byteshift == 0)
- return this->whole_file_view_;
+ return this->whole_file_view_;
off_t page = File_read::page_offset(start);
@@ -356,14 +351,8 @@ File_read::find_view(off_t start, section_size_type size,
&& (p->second->start() + static_cast<off_t>(p->second->size())
>= start + static_cast<off_t>(size)))
{
- if (byteshift == -1U || byteshift == p->second->byteshift())
- {
- p->second->set_accessed();
- return p->second;
- }
-
- if (vshifted != NULL && *vshifted == NULL)
- *vshifted = p->second;
+ p->second->set_accessed();
+ return p->second;
}
++p;
@@ -425,7 +414,7 @@ File_read::do_read(off_t start, section_size_type size, void* p)
void
File_read::read(off_t start, section_size_type size, void* p)
{
- const File_read::View* pv = this->find_view(start, size, -1U, NULL);
+ const File_read::View* pv = this->find_view(start, size);
if (pv != NULL)
{
memcpy(p, pv->data() + (start - pv->start() + pv->byteshift()), size);
@@ -469,7 +458,7 @@ File_read::add_view(File_read::View* v)
File_read::View*
File_read::make_view(off_t start, section_size_type size,
- unsigned int byteshift, bool cache)
+ bool cache)
{
gold_assert(size > 0);
gold_assert(start <= this->size_
@@ -488,36 +477,24 @@ File_read::make_view(off_t start, section_size_type size,
void* p;
View::Data_ownership ownership;
- if (byteshift != 0)
+ this->reopen_descriptor();
+ p = ::mmap(NULL, psize, PROT_READ, MAP_PRIVATE, this->descriptor_, poff);
+ if (p != MAP_FAILED)
{
- p = malloc(psize + byteshift);
- if (p == NULL)
- gold_nomem();
- memset(p, 0, byteshift);
- this->do_read(poff, psize, static_cast<unsigned char*>(p) + byteshift);
- ownership = View::DATA_ALLOCATED_ARRAY;
+ ownership = View::DATA_MMAPPED;
+ this->mapped_bytes_ += psize;
}
else
{
- this->reopen_descriptor();
- p = ::mmap(NULL, psize, PROT_READ, MAP_PRIVATE, this->descriptor_, poff);
- if (p != MAP_FAILED)
- {
- ownership = View::DATA_MMAPPED;
- this->mapped_bytes_ += psize;
- }
- else
- {
- p = malloc(psize);
- if (p == NULL)
- gold_nomem();
- this->do_read(poff, psize, p);
- ownership = View::DATA_ALLOCATED_ARRAY;
- }
+ p = malloc(psize);
+ if (p == NULL)
+ gold_nomem();
+ this->do_read(poff, psize, p);
+ ownership = View::DATA_ALLOCATED_ARRAY;
}
const unsigned char* pbytes = static_cast<const unsigned char*>(p);
- File_read::View* v = new File_read::View(poff, psize, pbytes, byteshift,
+ File_read::View* v = new File_read::View(poff, psize, pbytes, 0,
cache, ownership);
this->add_view(v);
@@ -530,7 +507,7 @@ File_read::make_view(off_t start, section_size_type size,
File_read::View*
File_read::find_or_make_view(off_t offset, off_t start,
- section_size_type size, bool aligned, bool cache)
+ section_size_type size, bool cache)
{
// Check that start and end of the view are within the file.
if (start > this->size_
@@ -566,13 +543,10 @@ File_read::find_or_make_view(off_t offset, off_t start,
if (this->whole_file_view_ == NULL
&& parameters->options_valid()
&& parameters->options().map_whole_files())
- this->whole_file_view_ = this->make_view(0, this->size_, 0, cache);
+ this->whole_file_view_ = this->make_view(0, this->size_, cache);
// Try to find a View with the required BYTESHIFT.
- File_read::View* vshifted;
- File_read::View* v = this->find_view(offset + start, size,
- aligned ? byteshift : -1U,
- &vshifted);
+ File_read::View* v = this->find_view(offset + start, size);
if (v != NULL)
{
if (cache)
@@ -580,52 +554,26 @@ File_read::find_or_make_view(off_t offset, off_t start,
return v;
}
- // If VSHIFTED is not NULL, then it has the data we need, but with
- // the wrong byteshift.
- v = vshifted;
- if (v != NULL)
- {
- gold_assert(aligned);
-
- unsigned char* pbytes;
- pbytes = static_cast<unsigned char*>(malloc(v->size() + byteshift));
- if (pbytes == NULL)
- gold_nomem();
- memset(pbytes, 0, byteshift);
- memcpy(pbytes + byteshift, v->data() + v->byteshift(), v->size());
-
- File_read::View* shifted_view =
- new File_read::View(v->start(), v->size(), pbytes, byteshift,
- cache, View::DATA_ALLOCATED_ARRAY);
-
- this->add_view(shifted_view);
- return shifted_view;
- }
-
- // Make a new view. If we don't need an aligned view, use a
- // byteshift of 0, so that we can use mmap.
- return this->make_view(offset + start, size,
- aligned ? byteshift : 0,
- cache);
+ // Make a new view.
+ return this->make_view(offset + start, size, cache);
}
// Get a view into the file.
const unsigned char*
File_read::get_view(off_t offset, off_t start, section_size_type size,
- bool aligned, bool cache)
+ bool cache)
{
File_read::View* pv = this->find_or_make_view(offset, start, size,
- aligned, cache);
+ cache);
return pv->data() + (offset + start - pv->start() + pv->byteshift());
}
File_view*
File_read::get_lasting_view(off_t offset, off_t start, section_size_type size,
- bool aligned, bool cache)
+ bool cache)
{
- File_read::View* pv = this->find_or_make_view(offset, start, size,
- aligned, cache);
+ File_read::View *pv = this->find_or_make_view(offset, start, size, cache);
pv->lock();
return new File_view(*this, pv,
(pv->data()
@@ -734,8 +682,7 @@ File_read::read_multiple(off_t base, const Read_multiple& rm)
else
{
File_read::View* view = this->find_view(base + i_off,
- end_off - i_off,
- -1U, NULL);
+ end_off - i_off);
if (view == NULL)
this->do_readv(base, rm, i, j - i);
else
diff --git a/gold/fileread.h b/gold/fileread.h
index 601e7b0..5d3cfea 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -150,8 +150,7 @@ class File_read
// get_view, read, or get_lasting_view which retrieve the same
// data.
const unsigned char*
- get_view(off_t offset, off_t start, section_size_type size, bool aligned,
- bool cache);
+ get_view(off_t offset, off_t start, section_size_type size, bool cache);
// Read data from the file into the buffer P starting at file offset
// START for SIZE bytes.
@@ -166,7 +165,7 @@ class File_read
// ALIGNED and CACHE parameters are as in get_view.
File_view*
get_lasting_view(off_t offset, off_t start, section_size_type size,
- bool aligned, bool cache);
+ bool cache);
// Mark all views as no longer cached.
void
@@ -367,8 +366,7 @@ class File_read
// Find a view into the file.
View*
- find_view(off_t start, section_size_type size, unsigned int byteshift,
- View** vshifted) const;
+ find_view(off_t start, section_size_type size) const;
// Read data from the file into a buffer.
void
@@ -380,13 +378,12 @@ class File_read
// Make a view into the file.
View*
- make_view(off_t start, section_size_type size, unsigned int byteshift,
- bool cache);
+ make_view(off_t start, section_size_type size, bool cache);
// Find or make a view into the file.
View*
find_or_make_view(off_t offset, off_t start, section_size_type size,
- bool aligned, bool cache);
+ bool cache);
// Clear the file views.
void
diff --git a/gold/gdb-index.cc b/gold/gdb-index.cc
index 666ee70..1006e7b 100644
--- a/gold/gdb-index.cc
+++ b/gold/gdb-index.cc
@@ -1293,8 +1293,8 @@ Gdb_index::do_write(Output_file* of)
base = (os->address()
+ object->output_section_offset(range.shndx));
}
- elfcpp::Swap_aligned32<64, false>::writeval(pov, base + range.start);
- elfcpp::Swap_aligned32<64, false>::writeval(pov + 8,
+ elfcpp::Swap<64, false>::writeval(pov, base + range.start);
+ elfcpp::Swap<64, false>::writeval(pov + 8,
base + range.end);
elfcpp::Swap<32, false>::writeval(pov + 16, cu_index);
pov += 20;
diff --git a/gold/i386.cc b/gold/i386.cc
index 086314e..bb3376d 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -1245,7 +1245,7 @@ Output_data_plt_i386_exec::do_fill_first_plt_entry(
elfcpp::Elf_types<32>::Elf_Addr got_address)
{
memcpy(pov, first_plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_address + 4);
+ elfcpp::Swap<32, false>::writeval(pov + 2, got_address + 4);
elfcpp::Swap<32, false>::writeval(pov + 8, got_address + 8);
}
@@ -1287,9 +1287,9 @@ Output_data_plt_i386_exec::do_fill_plt_entry(
unsigned int plt_rel_offset)
{
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
got_address + got_offset);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 7, plt_rel_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 7, plt_rel_offset);
elfcpp::Swap<32, false>::writeval(pov + 12, - (plt_offset + 12 + 4));
return 6;
}
@@ -1314,8 +1314,8 @@ Output_data_plt_i386_dyn::do_fill_plt_entry(unsigned char* pov,
unsigned int plt_rel_offset)
{
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_offset);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 7, plt_rel_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 2, got_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 7, plt_rel_offset);
elfcpp::Swap<32, false>::writeval(pov + 12, - (plt_offset + 12 + 4));
return 6;
}
@@ -3753,7 +3753,7 @@ Target_i386::do_code_fill(section_size_type length) const
// Build a jmp instruction to skip over the bytes.
unsigned char jmp[5];
jmp[0] = 0xe9;
- elfcpp::Swap_unaligned<32, false>::writeval(jmp + 1, length - 5);
+ elfcpp::Swap<32, false>::writeval(jmp + 1, length - 5);
return (std::string(reinterpret_cast<char*>(&jmp[0]), 5)
+ std::string(length - 5, static_cast<char>(0x90)));
}
@@ -3879,9 +3879,9 @@ Target_i386::do_calls_non_split(Relobj* object, unsigned int shndx,
// means we will avoid calling __morestack if there happens to
// be plenty of space on the stack already.
unsigned char* pval = view + fnoffset + 3;
- uint32_t val = elfcpp::Swap_unaligned<32, false>::readval(pval);
+ uint32_t val = elfcpp::Swap<32, false>::readval(pval);
val -= parameters->options().split_stack_adjust_size();
- elfcpp::Swap_unaligned<32, false>::writeval(pval, val);
+ elfcpp::Swap<32, false>::writeval(pval, val);
}
else
{
@@ -4084,7 +4084,7 @@ Output_data_plt_i386_nacl_exec::do_fill_first_plt_entry(
elfcpp::Elf_types<32>::Elf_Addr got_address)
{
memcpy(pov, first_plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_address + 4);
+ elfcpp::Swap<32, false>::writeval(pov + 2, got_address + 4);
elfcpp::Swap<32, false>::writeval(pov + 8, got_address + 8);
}
@@ -4153,9 +4153,9 @@ Output_data_plt_i386_nacl_exec::do_fill_plt_entry(
unsigned int plt_rel_offset)
{
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
got_address + got_offset);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 33, plt_rel_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 33, plt_rel_offset);
elfcpp::Swap<32, false>::writeval(pov + 38, - (plt_offset + 38 + 4));
return 32;
}
@@ -4196,8 +4196,8 @@ Output_data_plt_i386_nacl_dyn::do_fill_plt_entry(
unsigned int plt_rel_offset)
{
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_offset);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 33, plt_rel_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 2, got_offset);
+ elfcpp::Swap<32, false>::writeval(pov + 33, plt_rel_offset);
elfcpp::Swap<32, false>::writeval(pov + 38, - (plt_offset + 38 + 4));
return 32;
}
diff --git a/gold/int_encoding.h b/gold/int_encoding.h
index 07c5f45..d3464d3 100644
--- a/gold/int_encoding.h
+++ b/gold/int_encoding.h
@@ -103,9 +103,9 @@ void insert_into_vector(std::vector<unsigned char>* destination,
{
unsigned char buffer[valsize / 8];
if (parameters->target().is_big_endian())
- elfcpp::Swap_unaligned<valsize, true>::writeval(buffer, value);
+ elfcpp::Swap<valsize, true>::writeval(buffer, value);
else
- elfcpp::Swap_unaligned<valsize, false>::writeval(buffer, value);
+ elfcpp::Swap<valsize, false>::writeval(buffer, value);
destination->insert(destination->end(), buffer, buffer + valsize / 8);
}
@@ -117,9 +117,9 @@ read_from_pointer(const unsigned char* source)
{
typename elfcpp::Valtype_base<valsize>::Valtype return_value;
if (parameters->target().is_big_endian())
- return_value = elfcpp::Swap_unaligned<valsize, true>::readval(source);
+ return_value = elfcpp::Swap<valsize, true>::readval(source);
else
- return_value = elfcpp::Swap_unaligned<valsize, false>::readval(source);
+ return_value = elfcpp::Swap<valsize, false>::readval(source);
return return_value;
}
@@ -131,9 +131,9 @@ read_from_pointer(unsigned char** source)
{
typename elfcpp::Valtype_base<valsize>::Valtype return_value;
if (parameters->target().is_big_endian())
- return_value = elfcpp::Swap_unaligned<valsize, true>::readval(*source);
+ return_value = elfcpp::Swap<valsize, true>::readval(*source);
else
- return_value = elfcpp::Swap_unaligned<valsize, false>::readval(*source);
+ return_value = elfcpp::Swap<valsize, false>::readval(*source);
*source += valsize / 8;
return return_value;
}
@@ -146,9 +146,9 @@ read_from_pointer(const unsigned char** source)
{
typename elfcpp::Valtype_base<valsize>::Valtype return_value;
if (parameters->target().is_big_endian())
- return_value = elfcpp::Swap_unaligned<valsize, true>::readval(*source);
+ return_value = elfcpp::Swap<valsize, true>::readval(*source);
else
- return_value = elfcpp::Swap_unaligned<valsize, false>::readval(*source);
+ return_value = elfcpp::Swap<valsize, false>::readval(*source);
*source += valsize / 8;
return return_value;
}
diff --git a/gold/merge.cc b/gold/merge.cc
index 50d13af..d3a452a 100644
--- a/gold/merge.cc
+++ b/gold/merge.cc
@@ -457,7 +457,8 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
return false;
}
- if (pend[-1] != 0)
+ Char_type zero = 0;
+ if (memcmp(&zero, &pend[-1], sizeof(zero)) != 0)
{
gold_warning(_("%s: last entry in mergeable string section '%s' "
"not null terminated"),
diff --git a/gold/mips.cc b/gold/mips.cc
index acf76cf..5050880 100644
--- a/gold/mips.cc
+++ b/gold/mips.cc
@@ -5839,7 +5839,7 @@ Mips_relobj<size, big_endian>::do_count_local_symbols(
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// Loop over the local symbols and mark any MIPS16 or microMIPS local symbols.
@@ -5867,7 +5867,7 @@ Mips_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
// Read processor-specific flags in ELF file header.
const unsigned char* pehdr = this->get_view(elfcpp::file_header_offset,
elfcpp::Elf_sizes<size>::ehdr_size,
- true, false);
+ false);
elfcpp::Ehdr<size, big_endian> ehdr(pehdr);
this->processor_specific_flags_ = ehdr.get_e_flags();
@@ -5896,7 +5896,7 @@ Mips_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
section_size_type section_size =
convert_to_section_size_type(shdr.get_sh_size());
const unsigned char* view =
- this->get_view(section_offset, section_size, true, false);
+ this->get_view(section_offset, section_size, false);
this->gp_ = elfcpp::Swap<size, big_endian>::readval(view + 20);
@@ -8004,7 +8004,7 @@ Target_mips<size, big_endian>::do_finalize_sections(Layout* layout,
const unsigned char* pehdr = relobj->get_view(
elfcpp::file_header_offset,
elfcpp::Elf_sizes<size>::ehdr_size,
- true, false);
+ false);
elfcpp::Ehdr<size, big_endian> ehdr(pehdr);
elfcpp::Elf_Word in_flags = ehdr.get_e_flags();
@@ -8025,7 +8025,7 @@ Target_mips<size, big_endian>::do_finalize_sections(Layout* layout,
// Read processor-specific flags.
const unsigned char* pehdr = dynobj->get_view(elfcpp::file_header_offset,
elfcpp::Elf_sizes<size>::ehdr_size,
- true, false);
+ false);
elfcpp::Ehdr<size, big_endian> ehdr(pehdr);
elfcpp::Elf_Word in_flags = ehdr.get_e_flags();
diff --git a/gold/nacl.h b/gold/nacl.h
index 950a0c6..e338ffa 100644
--- a/gold/nacl.h
+++ b/gold/nacl.h
@@ -60,7 +60,7 @@ class Sniff_file
{
public:
View(File_read& file, off_t file_offset, off_t data_size)
- : data_(file.get_view(file_offset, 0, data_size, true, false))
+ : data_(file.get_view(file_offset, 0, data_size, false))
{ }
const unsigned char* data()
diff --git a/gold/object.cc b/gold/object.cc
index 4e94f7e..0562a50 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -121,7 +121,7 @@ Xindex::read_symtab_xindex(Object* object, unsigned int xindex_shndx,
* elfcpp::Elf_sizes<size>::shdr_size));
typename elfcpp::Shdr<size, big_endian> shdr(p);
bytecount = convert_to_section_size_type(shdr.get_sh_size());
- contents = object->get_view(shdr.get_sh_offset(), bytecount, true, false);
+ contents = object->get_view(shdr.get_sh_offset(), bytecount, false);
}
gold_assert(this->symtab_xindex_.empty());
@@ -196,7 +196,7 @@ Object::read_section_data(elfcpp::Elf_file<size, big_endian, Object>* elf_file,
const off_t shoff = elf_file->shoff();
const unsigned int shnum = this->shnum();
sd->section_headers = this->get_lasting_view(shoff, shnum * shdr_size,
- true, true);
+ true);
// Read the section names.
const unsigned char* pshdrs = sd->section_headers->data();
@@ -210,8 +210,7 @@ Object::read_section_data(elfcpp::Elf_file<size, big_endian, Object>* elf_file,
sd->section_names_size =
convert_to_section_size_type(shdrnames.get_sh_size());
sd->section_names = this->get_lasting_view(shdrnames.get_sh_offset(),
- sd->section_names_size, false,
- false);
+ sd->section_names_size, false);
}
// If NAME is the name of a special .gnu.warning section, arrange for
@@ -872,7 +871,7 @@ Sized_relobj_file<size, big_endian>::base_read_symbols(Read_symbols_data* sd)
return;
}
- File_view* fvsymtab = this->get_lasting_view(readoff, readsize, true, false);
+ File_view* fvsymtab = this->get_lasting_view(readoff, readsize, false);
// Read the section header for the symbol names.
unsigned int strtab_shndx = this->adjust_shndx(symtabshdr.get_sh_link());
@@ -892,7 +891,7 @@ Sized_relobj_file<size, big_endian>::base_read_symbols(Read_symbols_data* sd)
// Read the symbol names.
File_view* fvstrtab = this->get_lasting_view(strtabshdr.get_sh_offset(),
strtabshdr.get_sh_size(),
- false, true);
+ true);
sd->symbols = fvsymtab;
sd->symbols_size = readsize;
@@ -950,7 +949,7 @@ Sized_relobj_file<size, big_endian>::include_section_group(
// Read the section contents.
typename This::Shdr shdr(shdrs + index * This::shdr_size);
const unsigned char* pcon = this->get_view(shdr.get_sh_offset(),
- shdr.get_sh_size(), true, false);
+ shdr.get_sh_size(), false);
const elfcpp::Elf_Word* pword =
reinterpret_cast<const elfcpp::Elf_Word*>(pcon);
@@ -979,8 +978,7 @@ Sized_relobj_file<size, big_endian>::include_section_group(
return false;
}
off_t symoff = symshdr.get_sh_offset() + symndx * This::sym_size;
- const unsigned char* psym = this->get_view(symoff, This::sym_size, true,
- false);
+ const unsigned char* psym = this->get_view(symoff, This::sym_size, false);
elfcpp::Sym<size, big_endian> sym(psym);
// Read the symbol table names.
@@ -2160,7 +2158,7 @@ Sized_relobj_file<size, big_endian>::do_count_local_symbols(Stringpool* pool,
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
// Read the symbol names.
const unsigned int strtab_shndx =
@@ -2621,7 +2619,7 @@ Sized_relobj_file<size, big_endian>::write_local_symbols(
const int sym_size = This::sym_size;
off_t locsize = loccount * sym_size;
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- locsize, true, false);
+ locsize, false);
// Read the symbol names.
const unsigned int strtab_shndx =
@@ -3160,8 +3158,7 @@ is_elf_object(Input_file* input_file, off_t offset,
if (filesize - offset < want)
want = filesize - offset;
- const unsigned char* p = input_file->file().get_view(offset, 0, want,
- true, false);
+ const unsigned char *p = input_file->file().get_view(offset, 0, want, false);
*start = p;
*read_size = want;
diff --git a/gold/object.h b/gold/object.h
index a3d5d0e..5bdf60f 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -640,7 +640,7 @@ class Object
// Return a View.
View
view(off_t file_offset, section_size_type data_size)
- { return View(this->get_view(file_offset, data_size, true, true)); }
+ { return View(this->get_view(file_offset, data_size, true)); }
// Report an error.
void
@@ -659,23 +659,22 @@ class Object
// Get a View given a Location.
View view(Location loc)
- { return View(this->get_view(loc.file_offset, loc.data_size, true, true)); }
+ { return View(this->get_view(loc.file_offset, loc.data_size, true)); }
// Get a view into the underlying file.
const unsigned char*
- get_view(off_t start, section_size_type size, bool aligned, bool cache)
+ get_view(off_t start, section_size_type size, bool cache)
{
return this->input_file()->file().get_view(this->offset_, start, size,
- aligned, cache);
+ cache);
}
// Get a lasting view into the underlying file.
File_view*
- get_lasting_view(off_t start, section_size_type size, bool aligned,
- bool cache)
+ get_lasting_view(off_t start, section_size_type size, bool cache)
{
return this->input_file()->file().get_lasting_view(this->offset_, start,
- size, aligned, cache);
+ size, cache);
}
// Read data from the underlying file.
@@ -2350,7 +2349,7 @@ class Sized_relobj_file : public Sized_relobj<size, big_endian>
static const unsigned char empty[1] = { '\0' };
return empty;
}
- return this->get_view(loc.file_offset, *plen, true, cache);
+ return this->get_view(loc.file_offset, *plen, cache);
}
// Return section flags.
diff --git a/gold/output.cc b/gold/output.cc
index 5cc3629..f364db0 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -1979,15 +1979,15 @@ Output_fill_debug_info::do_write(Output_file* of, off_t off, size_t len) const
// address_size.
if (this->is_big_endian())
{
- elfcpp::Swap_unaligned<32, true>::writeval(pov, len - 4);
- elfcpp::Swap_unaligned<16, true>::writeval(pov + 4, this->version);
- elfcpp::Swap_unaligned<32, true>::writeval(pov + 6, 0);
+ elfcpp::Swap<32, true>::writeval(pov, len - 4);
+ elfcpp::Swap<16, true>::writeval(pov + 4, this->version);
+ elfcpp::Swap<32, true>::writeval(pov + 6, 0);
}
else
{
- elfcpp::Swap_unaligned<32, false>::writeval(pov, len - 4);
- elfcpp::Swap_unaligned<16, false>::writeval(pov + 4, this->version);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 6, 0);
+ elfcpp::Swap<32, false>::writeval(pov, len - 4);
+ elfcpp::Swap<16, false>::writeval(pov + 4, this->version);
+ elfcpp::Swap<32, false>::writeval(pov + 6, 0);
}
pov += 4 + 2 + 4;
*pov++ = 4;
@@ -2039,15 +2039,15 @@ Output_fill_debug_line::do_write(Output_file* of, off_t off, size_t len) const
// line number program is empty.
if (this->is_big_endian())
{
- elfcpp::Swap_unaligned<32, true>::writeval(pov, len - 4);
- elfcpp::Swap_unaligned<16, true>::writeval(pov + 4, this->version);
- elfcpp::Swap_unaligned<32, true>::writeval(pov + 6, len - (4 + 2 + 4));
+ elfcpp::Swap<32, true>::writeval(pov, len - 4);
+ elfcpp::Swap<16, true>::writeval(pov + 4, this->version);
+ elfcpp::Swap<32, true>::writeval(pov + 6, len - (4 + 2 + 4));
}
else
{
- elfcpp::Swap_unaligned<32, false>::writeval(pov, len - 4);
- elfcpp::Swap_unaligned<16, false>::writeval(pov + 4, this->version);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 6, len - (4 + 2 + 4));
+ elfcpp::Swap<32, false>::writeval(pov, len - 4);
+ elfcpp::Swap<16, false>::writeval(pov + 4, this->version);
+ elfcpp::Swap<32, false>::writeval(pov + 6, len - (4 + 2 + 4));
}
pov += 4 + 2 + 4;
*pov++ = 1; // minimum_instruction_length
diff --git a/gold/plugin.cc b/gold/plugin.cc
index 1588f34..c8e8f8a 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -822,8 +822,7 @@ Plugin_manager::get_view(unsigned int handle, const void **viewp)
filesize = obj->filesize();
input_file = obj->input_file();
}
- *viewp = (void*) input_file->file().get_view(offset, 0, filesize, false,
- false);
+ *viewp = (void*) input_file->file().get_view(offset, 0, filesize, false);
return LDPS_OK;
}
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 540e197..89940a1 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -1588,7 +1588,7 @@ private:
static inline Status
rela_ua(unsigned char* view, Address value, Overflow_check overflow)
{
- elfcpp::Swap_unaligned<fieldsize, big_endian>::writeval(view, value);
+ elfcpp::Swap<fieldsize, big_endian>::writeval(view, value);
return overflowed<valsize>(value, overflow);
}
@@ -1600,13 +1600,13 @@ private:
Address value,
Overflow_check overflow)
{
- typedef typename elfcpp::Swap_unaligned<fieldsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<fieldsize, big_endian>::Valtype
Valtype;
Valtype val = elfcpp::Swap<fieldsize, big_endian>::readval(view);
Valtype reloc = value >> right_shift;
val &= ~dst_mask;
reloc &= dst_mask;
- elfcpp::Swap_unaligned<fieldsize, big_endian>::writeval(view, val | reloc);
+ elfcpp::Swap<fieldsize, big_endian>::writeval(view, val | reloc);
return overflowed<valsize>(value >> right_shift, overflow);
}
@@ -1886,7 +1886,7 @@ Powerpc_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
const unsigned char *psymtab = pshdrs + symtab_shndx * shdr_size;
typename elfcpp::Shdr<size, big_endian> shdr(psymtab);
const unsigned char* psyms = this->get_view(shdr.get_sh_offset(),
- locsize, true, false);
+ locsize, false);
psyms += sym_size;
for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size)
{
@@ -1969,7 +1969,7 @@ Powerpc_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
this->opd_address_ = shdr.get_sh_addr();
opd_size = convert_to_section_size_type(shdr.get_sh_size());
opd = this->get_view(shdr.get_sh_offset(), opd_size,
- true, false);
+ false);
break;
}
}
diff --git a/gold/reloc.cc b/gold/reloc.cc
index 3c9f7a9..291c1a0 100644
--- a/gold/reloc.cc
+++ b/gold/reloc.cc
@@ -273,7 +273,7 @@ Sized_relobj_file<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
const unsigned char* pshdrs = this->get_view(this->elf_file_.shoff(),
shnum * This::shdr_size,
- true, true);
+ true);
// Skip the first, dummy, section.
const unsigned char* ps = pshdrs + This::shdr_size;
for (unsigned int i = 1; i < shnum; ++i, ps += This::shdr_size)
@@ -351,7 +351,7 @@ Sized_relobj_file<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
sr.reloc_shndx = i;
sr.data_shndx = shndx;
sr.contents = this->get_lasting_view(shdr.get_sh_offset(), sh_size,
- true, true);
+ true);
sr.sh_type = sh_type;
sr.reloc_count = reloc_count;
sr.output_section = os;
@@ -373,7 +373,7 @@ Sized_relobj_file<size, big_endian>::do_read_relocs(Read_relocs_data* rd)
gold_assert(loccount == symtabshdr.get_sh_info());
off_t locsize = loccount * sym_size;
rd->local_symbols = this->get_lasting_view(symtabshdr.get_sh_offset(),
- locsize, true, true);
+ locsize, true);
}
}
@@ -650,7 +650,7 @@ Sized_relobj_file<size, big_endian>::do_relocate(const Symbol_table* symtab,
// Read the section headers.
const unsigned char* pshdrs = this->get_view(this->elf_file_.shoff(),
shnum * This::shdr_size,
- true, true);
+ true);
Views views;
views.resize(shnum);
@@ -963,7 +963,7 @@ Sized_relobj_file<size, big_endian>::do_relocate_sections(
}
const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
- sh_size, true, false);
+ sh_size, false);
unsigned int reloc_size;
if (sh_type == elfcpp::SHT_REL)
@@ -1400,7 +1400,7 @@ Sized_relobj_file<size, big_endian>::find_functions(
typename elfcpp::Elf_types<size>::Elf_WXword sh_size =
symtabshdr.get_sh_size();
const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(),
- sh_size, true, true);
+ sh_size, true);
const int sym_size = This::sym_size;
const unsigned int symcount = sh_size / sym_size;
diff --git a/gold/reloc.h b/gold/reloc.h
index 559206e..fdd5a45 100644
--- a/gold/reloc.h
+++ b/gold/reloc.h
@@ -339,10 +339,10 @@ private:
rel_unaligned(unsigned char* view,
typename elfcpp::Swap<valsize, big_endian>::Valtype value)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
- Valtype x = elfcpp::Swap_unaligned<valsize, big_endian>::readval(view);
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, x + value);
+ Valtype x = elfcpp::Swap<valsize, big_endian>::readval(view);
+ elfcpp::Swap<valsize, big_endian>::writeval(view, x + value);
}
// Do a simple relocation using a Symbol_value with the addend in
@@ -368,11 +368,11 @@ private:
const Sized_relobj_file<size, big_endian>* object,
const Symbol_value<size>* psymval)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
- Valtype x = elfcpp::Swap_unaligned<valsize, big_endian>::readval(view);
+ Valtype x = elfcpp::Swap<valsize, big_endian>::readval(view);
x = psymval->value(object, x);
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, x);
+ elfcpp::Swap<valsize, big_endian>::writeval(view, x);
}
// Do a simple relocation with the addend in the relocation.
@@ -425,8 +425,8 @@ private:
typename elfcpp::Elf_types<size>::Elf_Addr address)
{
typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
- Valtype x = elfcpp::Swap_unaligned<valsize, big_endian>::readval(view);
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view,
+ Valtype x = elfcpp::Swap<valsize, big_endian>::readval(view);
+ elfcpp::Swap<valsize, big_endian>::writeval(view,
x + value - address);
}
diff --git a/gold/script-sections.cc b/gold/script-sections.cc
index 3e377aa..12da618 100644
--- a/gold/script-sections.cc
+++ b/gold/script-sections.cc
@@ -1065,13 +1065,13 @@ Output_data_expression::endian_write_to_buffer(uint64_t val,
switch (this->data_size())
{
case 1:
- elfcpp::Swap_unaligned<8, big_endian>::writeval(buf, val);
+ elfcpp::Swap<8, big_endian>::writeval(buf, val);
break;
case 2:
- elfcpp::Swap_unaligned<16, big_endian>::writeval(buf, val);
+ elfcpp::Swap<16, big_endian>::writeval(buf, val);
break;
case 4:
- elfcpp::Swap_unaligned<32, big_endian>::writeval(buf, val);
+ elfcpp::Swap<32, big_endian>::writeval(buf, val);
break;
case 8:
if (parameters->target().get_size() == 32)
@@ -1080,7 +1080,7 @@ Output_data_expression::endian_write_to_buffer(uint64_t val,
if (this->is_signed_ && (val & 0x80000000) != 0)
val |= 0xffffffff00000000LL;
}
- elfcpp::Swap_unaligned<64, big_endian>::writeval(buf, val);
+ elfcpp::Swap<64, big_endian>::writeval(buf, val);
break;
default:
gold_unreachable();
@@ -1204,7 +1204,7 @@ class Output_section_element_fill : public Output_section_element
gold_warning(_("fill value is not absolute"));
// FIXME: The GNU linker supports fill values of arbitrary length.
unsigned char fill_buff[4];
- elfcpp::Swap_unaligned<32, true>::writeval(fill_buff, fill_val);
+ elfcpp::Swap<32, true>::writeval(fill_buff, fill_val);
fill->assign(reinterpret_cast<char*>(fill_buff), 4);
}
@@ -2495,7 +2495,7 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab,
gold_warning(_("fill of section %s is not absolute"),
this->name_.c_str());
unsigned char fill_buff[4];
- elfcpp::Swap_unaligned<32, true>::writeval(fill_buff, fill_val);
+ elfcpp::Swap<32, true>::writeval(fill_buff, fill_val);
fill.assign(reinterpret_cast<char*>(fill_buff), 4);
}
diff --git a/gold/sparc.cc b/gold/sparc.cc
index d34585a..00d11f8 100644
--- a/gold/sparc.cc
+++ b/gold/sparc.cc
@@ -570,16 +570,16 @@ private:
const Symbol_value<size>* psymval,
typename elfcpp::Swap<size, big_endian>::Valtype addend)
{
- typedef typename elfcpp::Swap_unaligned<valsize,
+ typedef typename elfcpp::Swap<valsize,
big_endian>::Valtype Valtype;
unsigned char* wv = view;
- Valtype val = elfcpp::Swap_unaligned<valsize, big_endian>::readval(wv);
+ Valtype val = elfcpp::Swap<valsize, big_endian>::readval(wv);
Valtype reloc = (psymval->value(object, addend) >> right_shift);
val &= ~dst_mask;
reloc &= dst_mask;
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(wv, val | reloc);
+ elfcpp::Swap<valsize, big_endian>::writeval(wv, val | reloc);
}
// Do a simple PC relative relocation with a Symbol_value with the
@@ -614,12 +614,12 @@ private:
typename elfcpp::Swap<size, big_endian>::Valtype addend,
typename elfcpp::Elf_types<size>::Elf_Addr address)
{
- typedef typename elfcpp::Swap_unaligned<valsize,
+ typedef typename elfcpp::Swap<valsize,
big_endian>::Valtype Valtype;
unsigned char* wv = view;
Valtype reloc = (psymval->value(object, addend) - address);
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(wv, reloc);
+ elfcpp::Swap<valsize, big_endian>::writeval(wv, reloc);
}
typedef Sparc_relocate_functions<size, big_endian> This;
diff --git a/gold/stringpool.h b/gold/stringpool.h
index 2a3fb08..6950ade 100644
--- a/gold/stringpool.h
+++ b/gold/stringpool.h
@@ -38,8 +38,9 @@ template<typename Char_type>
inline size_t
string_length(const Char_type* p)
{
+ Char_type zero = 0;
size_t len = 0;
- for (; *p != 0; ++p)
+ for (; memcmp(&zero, p, sizeof(zero)) != 0; ++p)
++len;
return len;
}
diff --git a/gold/tilegx.cc b/gold/tilegx.cc
index 5d97271..5bd48d0 100644
--- a/gold/tilegx.cc
+++ b/gold/tilegx.cc
@@ -836,10 +836,10 @@ private:
elfcpp::Elf_Xword srshift, elfcpp::Elf_Xword doffset,
elfcpp::Elf_Xword bitmask)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
unsigned char* wv = view;
- Valtype val = elfcpp::Swap_unaligned<valsize, big_endian>::readval(wv);
+ Valtype val = elfcpp::Swap<valsize, big_endian>::readval(wv);
Valtype reloc = 0;
if (size == 32)
reloc = Bits<32>::sign_extend(psymval->value(object, addend)) >> srshift;
@@ -851,7 +851,7 @@ private:
val &= ~dst_mask;
reloc &= bitmask;
- elfcpp::Swap_unaligned<valsize, big_endian>::writeval(wv,
+ elfcpp::Swap<valsize, big_endian>::writeval(wv,
val | (reloc<<doffset));
}
@@ -925,7 +925,7 @@ private:
elfcpp::Elf_Xword bitmask)
{
- typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
+ typedef typename elfcpp::Swap<valsize, big_endian>::Valtype
Valtype;
unsigned char* wv = view;
Valtype reloc = 0;
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 007af1d..ff558a1 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -1502,7 +1502,7 @@ Output_data_plt_x86_64_standard<size>::do_fill_first_plt_entry(
{
memcpy(pov, first_plt_entry, plt_entry_size);
// We do a jmp relative to the PC at the end of this instruction.
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + 6)));
elfcpp::Swap<32, false>::writeval(pov + 8,
@@ -1543,10 +1543,10 @@ Output_data_plt_x86_64_standard<size>::do_fill_plt_entry(
plt_index + 1);
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
plt_got_pcrel_offset);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 7, plt_index);
+ elfcpp::Swap<32, false>::writeval(pov + 7, plt_index);
elfcpp::Swap<32, false>::writeval(pov + 12,
- (plt_offset + plt_entry_size));
@@ -1580,11 +1580,11 @@ Output_data_plt_x86_64_standard<size>::do_fill_tlsdesc_entry(
unsigned int plt_offset)
{
memcpy(pov, tlsdesc_plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + plt_offset
+ 6)));
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 8,
+ elfcpp::Swap<32, false>::writeval(pov + 8,
(got_base
+ tlsdesc_got_offset
- (plt_address + plt_offset
@@ -4458,7 +4458,7 @@ Target_x86_64<size>::do_code_fill(section_size_type length) const
// Build a jmpq instruction to skip over the bytes.
unsigned char jmp[5];
jmp[0] = 0xe9;
- elfcpp::Swap_unaligned<32, false>::writeval(jmp + 1, length - 5);
+ elfcpp::Swap<32, false>::writeval(jmp + 1, length - 5);
return (std::string(reinterpret_cast<char*>(&jmp[0]), 5)
+ std::string(length - 5, static_cast<char>(0x90)));
}
@@ -4620,9 +4620,9 @@ Target_x86_64<size>::do_calls_non_split(Relobj* object, unsigned int shndx,
// means we will avoid calling __morestack if there happens to
// be plenty of space on the stack already.
unsigned char* pval = view + fnoffset + 4;
- uint32_t val = elfcpp::Swap_unaligned<32, false>::readval(pval);
+ uint32_t val = elfcpp::Swap<32, false>::readval(pval);
val -= parameters->options().split_stack_adjust_size();
- elfcpp::Swap_unaligned<32, false>::writeval(pval, val);
+ elfcpp::Swap<32, false>::writeval(pval, val);
}
else
{
@@ -4868,10 +4868,10 @@ Output_data_plt_x86_64_nacl<size>::do_fill_first_plt_entry(
typename elfcpp::Elf_types<size>::Elf_Addr plt_address)
{
memcpy(pov, first_plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + 2 + 4)));
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 9,
+ elfcpp::Swap<32, false>::writeval(pov + 9,
(got_address + 16
- (plt_address + 9 + 4)));
}
@@ -4915,13 +4915,13 @@ Output_data_plt_x86_64_nacl<size>::do_fill_plt_entry(
unsigned int plt_index)
{
memcpy(pov, plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 3,
+ elfcpp::Swap<32, false>::writeval(pov + 3,
(got_address + got_offset
- (plt_address + plt_offset
+ 3 + 4)));
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 33, plt_index);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 38,
+ elfcpp::Swap<32, false>::writeval(pov + 33, plt_index);
+ elfcpp::Swap<32, false>::writeval(pov + 38,
- (plt_offset + 38 + 4));
return 32;
@@ -4961,11 +4961,11 @@ Output_data_plt_x86_64_nacl<size>::do_fill_tlsdesc_entry(
unsigned int plt_offset)
{
memcpy(pov, tlsdesc_plt_entry, plt_entry_size);
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ elfcpp::Swap<32, false>::writeval(pov + 2,
(got_address + 8
- (plt_address + plt_offset
+ 2 + 4)));
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 9,
+ elfcpp::Swap<32, false>::writeval(pov + 9,
(got_base
+ tlsdesc_got_offset
- (plt_address + plt_offset