This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: elf.c:3701: off += (m->sections[0]->vma - off) % bed->maxpagesize
- From: Andrew Cagney <cagney at gnu dot org>
- To: Ian Lance Taylor <ian at wasabisystems dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 21 Jan 2004 11:50:58 -0500
- Subject: Re: elf.c:3701: off += (m->sections[0]->vma - off) % bed->maxpagesize
- References: <400DE42B.7020100@gnu.org> <m3ad4ikls5.fsf@gossamer.airs.com>
Probably easiest to just cast OFF to ufile_ptr.
I'm testing a function that looks something like:
/* Ian Lance Taylor writes:
We shouldn't be using % with a negative signed number. That's just
not good. We have to make sure either that the number is not
negative, or that the number has an unsigned type. When the types
are all the same size they wind up as unsigned. When file_ptr is a
larger signed type, the arithmetic winds up as signed long long,
which is wrong.
What we're trying to say here is something like ``increase OFF by
the least amount that will cause it to be equal to the VMA modulo
the page size.'' */
/* In other words, something like:
vma_offset = m->sections[0]->vma % bed->maxpagesize;
off_offset = off % bed->maxpagesize;
if (vma_offset < off_offset)
adjustment = vma_offset + bed->maxpagesize - off_offset;
else
adjustment = vma_offset - off_offset;
this can be colapsed into the expression below. */
static ufile_ptr
offset_vma_page_adjustment (bfd_vma vma, ufile_ptr off, bfd_vma maxpagesize)
{
return ((vma - off) % maxpagesize);
}
I doubt there is much of this sort of arithmetic--though of course it
appears again 15 lines lower in the function.
as I've so far stumbled across ~6 occurances of that math (yes, couldn't
miss the one 15 lines below :-). Look ok?
Sill doesn't work but:
cagney@nettle$
/home/scratch/PENDING/2004-01-16-big-binutils/N-powerpc-unknown-netbsd1.6.1./ld/../binutils/nm-new
tmpdir/sizeof
00000040 D data_end
00000020 D data_start
00000020 A sizeof_data
00000020 A sizeof_text
00000010 T text_end
00000000 T text_start
note the value of sizeof_text.
arrg
Andrew