This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ELF/BFD: Hold the number of internal static relocs in `->reloc_count'


On Fri, 2 Jun 2017, Alan Modra wrote:

> > --- binutils.orig/bfd/elflink.c	2017-06-01 21:40:51.679023736 +0100
> > +++ binutils/bfd/elflink.c	2017-06-01 21:44:09.454957776 +0100
> > @@ -2450,8 +2450,7 @@ _bfd_elf_link_read_relocs (bfd *abfd,
> >      {
> >        bfd_size_type size;
> >  
> > -      size = o->reloc_count;
> > -      size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
> > +      size = o->reloc_count * sizeof (Elf_Internal_Rela);
> 
> Please cast o->reloc_count to bfd_size_type so that we continue to
> catch some cases of overflow here.

 I'll go with:

      size = o->reloc_count;
      size *= sizeof (Elf_Internal_Rela);

then if you don't mind.  I find explicit casts worsen code readability.

  Maciej


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]