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: bfd/elf.c: more wrap/overlap/overflow weirdness


On Thu, Aug 26, 2010 at 10:22:13PM -0400, DJ Delorie wrote:
> 
> > +	      /* A wrapping section potentially clashes with header.  */
> > +	      if (((s->lma + s->size) & addr_mask) < (s->lma & addr_mask))
> > +		wrap_to = (s->lma + s->size) & addr_mask;
> 
> If a section is non-empty and ends *at* the end of the target memory,
> wrap_to is zero...

Which is what you want

> > +	      || (sections[0]->lma & addr_mask & -maxpagesize) < wrap_to)
> 
> ...and is that test wrong?

because you'll never get an unsigned value less than zero.  The lhs of
that comparison trying to calculate the header lma.  I think it is
correct, at least for cases where sections[0]->lma meets the previous
tests.

> This is what I've got so far, but I suspect this code needs an
> addrmask just like yours...

Yes, it probably should have addrmask.  Do you still need to tweak the
"lma adjusted warning" code?  The testcase you posted no longer has a
problem.

-- 
Alan Modra
Australia Development Lab, IBM


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