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: loadbase alignment - ld.so/prelink/kernel or bfd_elf_bfd_from_remote_memory() bug?


On Wed, 15 Aug 2007 16:03:02 +0200, H.J. Lu wrote:
> On Wed, Aug 15, 2007 at 03:56:10PM +0200, Jan Kratochvil wrote:
...
> > --- glibc-20070810T2152-orig/elf/dl-load.c	2007-08-03 17:50:24.000000000 +0200
> > +++ glibc-20070810T2152/elf/dl-load.c	2007-08-15 00:41:03.000000000 +0200
> > @@ -1012,6 +1012,7 @@ _dl_map_object_from_fd (const char *name
> >  	int prot;
> >        } loadcmds[l->l_phnum], *c;
> >      size_t nloadcmds = 0;
> > +    ElfW(Addr) alignmax = GLRO(dl_pagesize);
> 
> Why not replace all GLRO(dl_pagesize) with alignmax?

The final ELF mapping start address is decided by the call:
	l->l_map_start = (ElfW(Addr)) __mmap ((void *) mappref, maplength,
					      c->prot,
					      MAP_COPY|MAP_FILE,
					      fd, c->mapoff);

Even if you have MAPPREF properly aligned kernel still may choose any address
>= MAPPREF being only PAGE_SIZE aligned.  There should be a kernel mmap()
syscall alignment parameter which does not exist, therefore it must be emulated
by hand as my patch does.

The current use of `GLRO(dl_pagesize)' inside `case PT_LOAD' has meaning only
for ET_EXEC files as the address gets recalculated for ET_DYN files later.
ET_EXEC files base address cannot be changed so this patch should not change
their behavior.

Sorry if I did not understand your suggestion.


Regards,
Jan


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