mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 22:48:57 +08:00
* powerpc.cc (Powerpc_relocate_functions): Upcase enum values,
update all uses and lose "enum" when using type.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2012-09-05 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* powerpc.cc (Powerpc_relocate_functions): Upcase enum values,
|
||||||
|
update all uses and lose "enum" when using type.
|
||||||
|
|
||||||
2012-09-05 Alan Modra <amodra@gmail.com>
|
2012-09-05 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): False for powerpc.
|
* configure.ac (FN_PTRS_IN_SO_WITHOUT_PIC): False for powerpc.
|
||||||
|
119
gold/powerpc.cc
119
gold/powerpc.cc
@ -845,18 +845,18 @@ template<int size, bool big_endian>
|
|||||||
class Powerpc_relocate_functions
|
class Powerpc_relocate_functions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum overflow_check
|
enum Overflow_check
|
||||||
{
|
{
|
||||||
check_none,
|
CHECK_NONE,
|
||||||
check_signed,
|
CHECK_SIGNED,
|
||||||
check_bitfield
|
CHECK_BITFIELD
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum overflow_status
|
enum Status
|
||||||
{
|
{
|
||||||
status_ok,
|
STATUS_OK,
|
||||||
status_overflow
|
STATUS_OVERFLOW
|
||||||
} Status;
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef Powerpc_relocate_functions<size, big_endian> This;
|
typedef Powerpc_relocate_functions<size, big_endian> This;
|
||||||
@ -884,26 +884,26 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<int valsize>
|
template<int valsize>
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
overflowed(Address value, enum overflow_check overflow)
|
overflowed(Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
if (overflow == check_signed)
|
if (overflow == CHECK_SIGNED)
|
||||||
{
|
{
|
||||||
if (has_overflow_signed<valsize>(value))
|
if (has_overflow_signed<valsize>(value))
|
||||||
return status_overflow;
|
return STATUS_OVERFLOW;
|
||||||
}
|
}
|
||||||
else if (overflow == check_bitfield)
|
else if (overflow == CHECK_BITFIELD)
|
||||||
{
|
{
|
||||||
if (has_overflow_bitfield<valsize>(value))
|
if (has_overflow_bitfield<valsize>(value))
|
||||||
return status_overflow;
|
return STATUS_OVERFLOW;
|
||||||
}
|
}
|
||||||
return status_ok;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do a simple RELA relocation
|
// Do a simple RELA relocation
|
||||||
template<int valsize>
|
template<int valsize>
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
rela(unsigned char* view, Address value, enum overflow_check overflow)
|
rela(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
|
typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
|
||||||
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
||||||
@ -912,12 +912,12 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<int valsize>
|
template<int valsize>
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
rela(unsigned char* view,
|
rela(unsigned char* view,
|
||||||
unsigned int right_shift,
|
unsigned int right_shift,
|
||||||
typename elfcpp::Valtype_base<valsize>::Valtype dst_mask,
|
typename elfcpp::Valtype_base<valsize>::Valtype dst_mask,
|
||||||
Address value,
|
Address value,
|
||||||
enum overflow_check overflow)
|
Overflow_check overflow)
|
||||||
{
|
{
|
||||||
typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
|
typedef typename elfcpp::Swap<valsize, big_endian>::Valtype Valtype;
|
||||||
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
Valtype* wv = reinterpret_cast<Valtype*>(view);
|
||||||
@ -931,20 +931,20 @@ private:
|
|||||||
|
|
||||||
// Do a simple RELA relocation, unaligned.
|
// Do a simple RELA relocation, unaligned.
|
||||||
template<int valsize>
|
template<int valsize>
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
rela_ua(unsigned char* view, Address value, enum overflow_check overflow)
|
rela_ua(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, value);
|
elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, value);
|
||||||
return overflowed<valsize>(value, overflow);
|
return overflowed<valsize>(value, overflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int valsize>
|
template<int valsize>
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
rela_ua(unsigned char* view,
|
rela_ua(unsigned char* view,
|
||||||
unsigned int right_shift,
|
unsigned int right_shift,
|
||||||
typename elfcpp::Valtype_base<valsize>::Valtype dst_mask,
|
typename elfcpp::Valtype_base<valsize>::Valtype dst_mask,
|
||||||
Address value,
|
Address value,
|
||||||
enum overflow_check overflow)
|
Overflow_check overflow)
|
||||||
{
|
{
|
||||||
typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
|
typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype
|
||||||
Valtype;
|
Valtype;
|
||||||
@ -960,59 +960,57 @@ public:
|
|||||||
// R_PPC64_ADDR64: (Symbol + Addend)
|
// R_PPC64_ADDR64: (Symbol + Addend)
|
||||||
static inline void
|
static inline void
|
||||||
addr64(unsigned char* view, Address value)
|
addr64(unsigned char* view, Address value)
|
||||||
{ This::template rela<64>(view, value, check_none); }
|
{ This::template rela<64>(view, value, CHECK_NONE); }
|
||||||
|
|
||||||
// R_PPC64_UADDR64: (Symbol + Addend) unaligned
|
// R_PPC64_UADDR64: (Symbol + Addend) unaligned
|
||||||
static inline void
|
static inline void
|
||||||
addr64_u(unsigned char* view, Address value)
|
addr64_u(unsigned char* view, Address value)
|
||||||
{ This::template rela_ua<64>(view, value, check_none); }
|
{ This::template rela_ua<64>(view, value, CHECK_NONE); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR32: (Symbol + Addend)
|
// R_POWERPC_ADDR32: (Symbol + Addend)
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr32(unsigned char* view, Address value, enum overflow_check overflow)
|
addr32(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{ return This::template rela<32>(view, value, overflow); }
|
{ return This::template rela<32>(view, value, overflow); }
|
||||||
|
|
||||||
// R_POWERPC_UADDR32: (Symbol + Addend) unaligned
|
// R_POWERPC_UADDR32: (Symbol + Addend) unaligned
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr32_u(unsigned char* view, Address value, enum overflow_check overflow)
|
addr32_u(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{ return This::template rela_ua<32>(view, value, overflow); }
|
{ return This::template rela_ua<32>(view, value, overflow); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR24: (Symbol + Addend) & 0x3fffffc
|
// R_POWERPC_ADDR24: (Symbol + Addend) & 0x3fffffc
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr24(unsigned char* view, Address value, enum overflow_check overflow)
|
addr24(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
enum overflow_status stat
|
Status stat = This::template rela<32>(view, 0, 0x03fffffc, value, overflow);
|
||||||
= This::template rela<32>(view, 0, 0x03fffffc, value, overflow);
|
if (overflow != CHECK_NONE && (value & 3) != 0)
|
||||||
if (overflow != check_none && (value & 3) != 0)
|
stat = STATUS_OVERFLOW;
|
||||||
stat = status_overflow;
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// R_POWERPC_ADDR16: (Symbol + Addend) & 0xffff
|
// R_POWERPC_ADDR16: (Symbol + Addend) & 0xffff
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr16(unsigned char* view, Address value, enum overflow_check overflow)
|
addr16(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{ return This::template rela<16>(view, value, overflow); }
|
{ return This::template rela<16>(view, value, overflow); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR16: (Symbol + Addend) & 0xffff, unaligned
|
// R_POWERPC_ADDR16: (Symbol + Addend) & 0xffff, unaligned
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr16_u(unsigned char* view, Address value, enum overflow_check overflow)
|
addr16_u(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{ return This::template rela_ua<16>(view, value, overflow); }
|
{ return This::template rela_ua<16>(view, value, overflow); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR16_DS: (Symbol + Addend) & 0xfffc
|
// R_POWERPC_ADDR16_DS: (Symbol + Addend) & 0xfffc
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr16_ds(unsigned char* view, Address value, enum overflow_check overflow)
|
addr16_ds(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
enum overflow_status stat
|
Status stat = This::template rela<16>(view, 0, 0xfffc, value, overflow);
|
||||||
= This::template rela<16>(view, 0, 0xfffc, value, overflow);
|
if (overflow != CHECK_NONE && (value & 3) != 0)
|
||||||
if (overflow != check_none && (value & 3) != 0)
|
stat = STATUS_OVERFLOW;
|
||||||
stat = status_overflow;
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// R_POWERPC_ADDR16_HI: ((Symbol + Addend) >> 16) & 0xffff
|
// R_POWERPC_ADDR16_HI: ((Symbol + Addend) >> 16) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
addr16_hi(unsigned char* view, Address value)
|
addr16_hi(unsigned char* view, Address value)
|
||||||
{ This::template rela<16>(view, 16, 0xffff, value, check_none); }
|
{ This::template rela<16>(view, 16, 0xffff, value, CHECK_NONE); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR16_HA: ((Symbol + Addend + 0x8000) >> 16) & 0xffff
|
// R_POWERPC_ADDR16_HA: ((Symbol + Addend + 0x8000) >> 16) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
@ -1022,7 +1020,7 @@ public:
|
|||||||
// R_POWERPC_ADDR16_HIGHER: ((Symbol + Addend) >> 32) & 0xffff
|
// R_POWERPC_ADDR16_HIGHER: ((Symbol + Addend) >> 32) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
addr16_hi2(unsigned char* view, Address value)
|
addr16_hi2(unsigned char* view, Address value)
|
||||||
{ This::template rela<16>(view, 32, 0xffff, value, check_none); }
|
{ This::template rela<16>(view, 32, 0xffff, value, CHECK_NONE); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR16_HIGHERA: ((Symbol + Addend + 0x8000) >> 32) & 0xffff
|
// R_POWERPC_ADDR16_HIGHERA: ((Symbol + Addend + 0x8000) >> 32) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
@ -1032,7 +1030,7 @@ public:
|
|||||||
// R_POWERPC_ADDR16_HIGHEST: ((Symbol + Addend) >> 48) & 0xffff
|
// R_POWERPC_ADDR16_HIGHEST: ((Symbol + Addend) >> 48) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
addr16_hi3(unsigned char* view, Address value)
|
addr16_hi3(unsigned char* view, Address value)
|
||||||
{ This::template rela<16>(view, 48, 0xffff, value, check_none); }
|
{ This::template rela<16>(view, 48, 0xffff, value, CHECK_NONE); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR16_HIGHESTA: ((Symbol + Addend + 0x8000) >> 48) & 0xffff
|
// R_POWERPC_ADDR16_HIGHESTA: ((Symbol + Addend + 0x8000) >> 48) & 0xffff
|
||||||
static inline void
|
static inline void
|
||||||
@ -1040,13 +1038,12 @@ public:
|
|||||||
{ This::addr16_hi3(view, value + 0x8000); }
|
{ This::addr16_hi3(view, value + 0x8000); }
|
||||||
|
|
||||||
// R_POWERPC_ADDR14: (Symbol + Addend) & 0xfffc
|
// R_POWERPC_ADDR14: (Symbol + Addend) & 0xfffc
|
||||||
static inline enum overflow_status
|
static inline Status
|
||||||
addr14(unsigned char* view, Address value, enum overflow_check overflow)
|
addr14(unsigned char* view, Address value, Overflow_check overflow)
|
||||||
{
|
{
|
||||||
enum overflow_status stat
|
Status stat = This::template rela<32>(view, 0, 0xfffc, value, overflow);
|
||||||
= This::template rela<32>(view, 0, 0xfffc, value, overflow);
|
if (overflow != CHECK_NONE && (value & 3) != 0)
|
||||||
if (overflow != check_none && (value & 3) != 0)
|
stat = STATUS_OVERFLOW;
|
||||||
stat = status_overflow;
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -3579,18 +3576,18 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Reloc::overflow_check overflow = Reloc::check_none;
|
typename Reloc::Overflow_check overflow = Reloc::CHECK_NONE;
|
||||||
switch (r_type)
|
switch (r_type)
|
||||||
{
|
{
|
||||||
case elfcpp::R_POWERPC_ADDR32:
|
case elfcpp::R_POWERPC_ADDR32:
|
||||||
case elfcpp::R_POWERPC_UADDR32:
|
case elfcpp::R_POWERPC_UADDR32:
|
||||||
if (size == 64)
|
if (size == 64)
|
||||||
overflow = Reloc::check_bitfield;
|
overflow = Reloc::CHECK_BITFIELD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case elfcpp::R_POWERPC_REL32:
|
case elfcpp::R_POWERPC_REL32:
|
||||||
if (size == 64)
|
if (size == 64)
|
||||||
overflow = Reloc::check_signed;
|
overflow = Reloc::CHECK_SIGNED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case elfcpp::R_POWERPC_ADDR24:
|
case elfcpp::R_POWERPC_ADDR24:
|
||||||
@ -3600,7 +3597,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
|
|||||||
case elfcpp::R_POWERPC_ADDR14:
|
case elfcpp::R_POWERPC_ADDR14:
|
||||||
case elfcpp::R_POWERPC_ADDR14_BRTAKEN:
|
case elfcpp::R_POWERPC_ADDR14_BRTAKEN:
|
||||||
case elfcpp::R_POWERPC_ADDR14_BRNTAKEN:
|
case elfcpp::R_POWERPC_ADDR14_BRNTAKEN:
|
||||||
overflow = Reloc::check_bitfield;
|
overflow = Reloc::CHECK_BITFIELD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case elfcpp::R_POWERPC_REL24:
|
case elfcpp::R_POWERPC_REL24:
|
||||||
@ -3624,12 +3621,12 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
|
|||||||
case elfcpp::R_POWERPC_GOT_TLSLD16:
|
case elfcpp::R_POWERPC_GOT_TLSLD16:
|
||||||
case elfcpp::R_POWERPC_GOT_TPREL16:
|
case elfcpp::R_POWERPC_GOT_TPREL16:
|
||||||
case elfcpp::R_POWERPC_GOT_DTPREL16:
|
case elfcpp::R_POWERPC_GOT_DTPREL16:
|
||||||
overflow = Reloc::check_signed;
|
overflow = Reloc::CHECK_SIGNED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename Powerpc_relocate_functions<size, big_endian>::Status status
|
typename Powerpc_relocate_functions<size, big_endian>::Status status
|
||||||
= Powerpc_relocate_functions<size, big_endian>::status_ok;
|
= Powerpc_relocate_functions<size, big_endian>::STATUS_OK;
|
||||||
switch (r_type)
|
switch (r_type)
|
||||||
{
|
{
|
||||||
case elfcpp::R_POWERPC_NONE:
|
case elfcpp::R_POWERPC_NONE:
|
||||||
@ -3859,7 +3856,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
|
|||||||
r_type);
|
r_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (status != Powerpc_relocate_functions<size, big_endian>::status_ok)
|
if (status != Powerpc_relocate_functions<size, big_endian>::STATUS_OK)
|
||||||
gold_error_at_location(relinfo, relnum, rela.get_r_offset(),
|
gold_error_at_location(relinfo, relnum, rela.get_r_offset(),
|
||||||
_("relocation overflow"));
|
_("relocation overflow"));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user