Bug 1048 - MIPS page size support for shared objects dlopen()ed from static ones
Summary: MIPS page size support for shared objects dlopen()ed from static ones
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: ports (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: drow@false.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-04 15:35 UTC by Maciej W. Rozycki
Modified: 2009-01-27 16:52 UTC (History)
4 users (show)

See Also:
Host: mipsel-unknown-linux-gnu
Target:
Build:
Last reconfirmed:


Attachments
glibc-2.3.90-20050704-mips-dl-static.patch (2.59 KB, patch)
2005-07-04 15:36 UTC, Maciej W. Rozycki
Details | Diff
replacement of the libc-port part of the mips-dl-static.patch (1.74 KB, patch)
2009-01-05 12:55 UTC, Atsushi Nemoto
Details | Diff
updated mips-dl-static.patch which does all things in ports (1.84 KB, patch)
2009-01-08 15:00 UTC, Atsushi Nemoto
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej W. Rozycki 2005-07-04 15:35:58 UTC
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.
Comment 1 Maciej W. Rozycki 2005-07-04 15:36:35 UTC
Created attachment 541 [details]
glibc-2.3.90-20050704-mips-dl-static.patch
Comment 2 Roland McGrath 2006-02-21 02:14:26 UTC
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.
Comment 3 Daniel Jacobowitz 2006-07-24 14:18:41 UTC
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.
Comment 4 Maciej W. Rozycki 2006-07-24 14:53:48 UTC
 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.
Comment 5 drow@false.org 2006-07-24 14:58:51 UTC
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.

Comment 6 Atsushi Nemoto 2009-01-05 12:50:28 UTC
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.

Comment 7 Atsushi Nemoto 2009-01-05 12:55:50 UTC
Created attachment 3635 [details]
replacement of the libc-port part of the mips-dl-static.patch
Comment 8 Atsushi Nemoto 2009-01-08 15:00:03 UTC
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.
Comment 9 Sourceware Commits 2009-01-27 15:33:06 UTC
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

Comment 10 Daniel Jacobowitz 2009-01-27 16:52:24 UTC
Patch checked in.