[uClibc]Address alignment in dynamic linker

Tobias Anderberg tobias.anderberg at axis.com
Thu May 16 14:27:06 UTC 2002


Tobias Anderberg wrote:

> Hi!
>
> While finishing up the port for the CRIS architecture I noticed that
> the address alignment done in the dynamic linker is hardcoded for
> architectures with a page size of 4k. Naturally this doesn't work
> very well on architectures with another page size!
>
> So I propose the use of macros when doing the alignments. Though I
> havn't found the optimal place where to define these macros, I'm
> leaning on defining them in ../ldso/ldso/<arch>/ld_sysdep.h, like:
>
> #define PAGE_ALIGN 0xffffe000  /* 8k pages */
> #define ADDR_ALIGN 0x1ff
>
> Then in ../ldso/ldso/readelflib1.c, for instance, we do something
> like the following on every alignment:
>
> status = _dl_mmap((char *) ((piclib ? libaddr : 0) +
>          (ppnt->p_vaddr & PAGE_ALIGN)), (ppnt->p_vaddr & ADDR_ALIGN)
>          + ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags, infile,
>          ppnt->p_offset & PAGE_ALIGN);
                            ^^^^^^^^^^

This last one should be defined with a corresponding OFFS_ALIGN, of
course, since it's not the same as the PAGE_ALIGN! D'oh! :-)

/tobba




More information about the uClibc mailing list