Complementing the change to support variable page sizes for MIPS, here is an update to make getpagesize() work correctly for shared objects pulled by dlopen() from static executables. As the area used originally for the auxiliary vector cannot be trusted anymore at this point, the page size is passed from dlopen() to an auxiliary ld.so initializer explicitly. For this to work the RELRO segment needs to be updated, which unfortunately requires a somewhat complicated sequence of steps to turn on write permission beforehand and turn it off again afterwards. Here are the necessary changes. 2005-07-04 Maciej W. Rozycki <macro@linux-mips.org> * elf/dl-reloc.c (_dl_protect_relro): Expect and handle an additional argument specifying protection mode to use. Update error messages accordingly. (_dl_relocate_object): Update the call to _dl_protect_relro(). * elf/rtld.c (dl_main): Likewise. * sysdeps/generic/ldsodefs.h (_dl_protect_relro): Update the prototype. * sysdeps/unix/sysv/linux/mips/dl-static.c: New file to support variable page size for MIPS. * sysdeps/unix/sysv/linux/mips/ldsodefs.h: Likewise. * sysdeps/unix/sysv/linux/mips/Dist: Add dl-static.c. * sysdeps/unix/sysv/linux/mips/Makefile: Build dl-static in elf. * sysdeps/unix/sysv/linux/mips/Versions: Add _dl_var_init. See: "http://sourceware.org/ml/libc-alpha/2003-12/msg00159.html" for an additional reference.
Created attachment 541 [details] glibc-2.3.90-20050704-mips-dl-static.patch
For the trunk, mips has moved to the ports repository. Daniel should be able to commit his fixes there directly. Items needing merge in the 2.3 branch can be reassigned to me.
I can't approve this patch; it still touches things in elf/. The referenced mailing list discussion doesn't seem to have a conclusion at the end of it as to whether they were required.
The dl_pagesize variable is in the RELRO segment. At the point _dl_static_init() is called this segment has already been write-protected. Therefore to initialize the variable, the segment has to be made writable beforehand and then reset to read-only afterwards. I have chosen to reuse _dl_protect_relro() for fiddling with the permissions as it already has all the necessary bits, except from the ability to specify permissions different to currently hardcoded PROT_READ. If you would rather prefer another function, say _dl_unprotect_relro(), doing the same what _dl_protect_relro() does, except from hardcoding PROT_READ | PROT_WRITE instead, that is easily doable, but of questionable gain. My understanding is IA64 currently goes away without hitting the problem, because ld does not create the RELRO segment for this architecture as COMMONPAGESIZE is unset. It looks like the intent is to enable the setting eventually (see emulparams/elf64_ia64.sh for details), which will result in the same issue that hit me when implementing initialization of dl_pagesize for MIPS. I hope this is clear enough now.
Subject: Re: MIPS page size support for shared objects dlopen()ed from static ones On Mon, Jul 24, 2006 at 02:53:48PM -0000, macro at linux-mips dot org wrote: > I hope this is clear enough now. It's clear enough to me, but I can't commit things to elf/; I'll see what Roland says.
I updated the libc-ports part of the glibc-2.3.90-20050704-mips-dl-static.patch. See http://sourceware.org/ml/libc-ports/2009-01/msg00004.html for background.
Created attachment 3635 [details] replacement of the libc-port part of the mips-dl-static.patch
Created attachment 3646 [details] updated mips-dl-static.patch which does all things in ports Looking at original patch closer, I realize that whole thing can be done in ports.
Subject: Bug 1048 CVSROOT: /cvs/glibc Module name: ports Changes by: drow@sourceware.org 2009-01-27 15:32:55 Modified files: . : ChangeLog.mips sysdeps/unix/sysv/linux/mips: Makefile Versions Added files: sysdeps/unix/sysv/linux/mips: dl-static.c ldsodefs.h Log message: PR glibc/1048 * sysdeps/unix/sysv/linux/mips/dl-static.c: New file to support variable page size for MIPS. * sysdeps/unix/sysv/linux/mips/ldsodefs.h: Likewise. * sysdeps/unix/sysv/linux/mips/Makefile: Build dl-static in elf. * sysdeps/unix/sysv/linux/mips/Versions: Add _dl_var_init. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/ports/ChangeLog.mips.diff?cvsroot=glibc&r1=1.69&r2=1.70 http://sourceware.org/cgi-bin/cvsweb.cgi/ports/sysdeps/unix/sysv/linux/mips/dl-static.c.diff?cvsroot=glibc&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h.diff?cvsroot=glibc&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/ports/sysdeps/unix/sysv/linux/mips/Makefile.diff?cvsroot=glibc&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/ports/sysdeps/unix/sysv/linux/mips/Versions.diff?cvsroot=glibc&r1=1.9&r2=1.10
Patch checked in.