https://sourceware.org/bugzilla/show_bug.cgi?id=19577
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> --- powerpc.cc has working address overflow check: template<int size, bool big_endian> class Powerpc_relocate_functions { public: enum Overflow_check { CHECK_NONE, CHECK_SIGNED, CHECK_UNSIGNED, CHECK_BITFIELD, CHECK_LOW_INSN, CHECK_HIGH_INSN }; enum Status { STATUS_OK, STATUS_OVERFLOW }; private: typedef Powerpc_relocate_functions<size, big_endian> This; typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; typedef typename elfcpp::Elf_types<size>::Elf_Swxword SignedAddress; template<int valsize> static inline bool has_overflow_signed(Address value) { // limit = 1 << (valsize - 1) without shift count exceeding size of type Address limit = static_cast<Address>(1) << ((valsize - 1) >> 1); limit <<= ((valsize - 1) >> 1); limit <<= ((valsize - 1) - 2 * ((valsize - 1) >> 1)); return value + limit > (limit << 1) - 1; } template<int valsize> static inline bool has_overflow_unsigned(Address value) { Address limit = static_cast<Address>(1) << ((valsize - 1) >> 1); limit <<= ((valsize - 1) >> 1); limit <<= ((valsize - 1) - 2 * ((valsize - 1) >> 1)); return value > (limit << 1) - 1; } template<int valsize> static inline bool has_overflow_bitfield(Address value) { return (has_overflow_unsigned<valsize>(value) && has_overflow_signed<valsize>(value)); } -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils