[PATCH] PR gold/18695
H.J. Lu
hjl.tools@gmail.com
Wed Aug 26 13:13:00 GMT 2015
More information about the Binutils mailing list
Wed Aug 26 13:13:00 GMT 2015
- Previous message (by thread): [PATCH] PR gold/18695
- Next message (by thread): [PATCH] PR gold/18695
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Aug 26, 2015 at 6:11 AM, Andrew Senkevich <andrew.n.senkevich@gmail.com> wrote: > Hi, > > is this patch ok? > > 2015-08-26 Andrew Senkevich <andrew.senkevich@intel.com> > > PR gold/18695 > * x86_64.cc: Overflow checks added. > > diff --git a/gold/x86_64.cc b/gold/x86_64.cc > index 007af1d..2d0712f 100644 > --- a/gold/x86_64.cc > +++ b/gold/x86_64.cc > @@ -3320,6 +3320,32 @@ Target_x86_64<size>::do_finalize_sections( > } > } > > +template<int size, int valsize> > +class x86_64_overflow_check > +{ > +public: > + typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; > + > + 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; > + } > + > + 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; > + } > +}; > + > // Perform a relocation. Shouldn't there be generic address overflow checks which can be used by all targets? -- H.J.
- Previous message (by thread): [PATCH] PR gold/18695
- Next message (by thread): [PATCH] PR gold/18695
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list