This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: [patch] Variable page size support for MIPS/Linux


On Mon, 5 Jan 2004, Roland McGrath wrote:

> >  As Linux uses the auxiliary vector to report the page size,
> > _dl_non_dynamic_init() is not used for initializing _dl_pagesize;
> > _dl_aux_init() is used instead.
> 
> Both of these do get called, and both of them will initialize _dl_pagesize.
> Look at _dl_non_dynamic_init.

 Neither of them is used for ld.so -- they are for static executables 
only.

 As a side note, the following code in _dl_non_dynamic_init() you are
supposedly referring to:

  if (!_dl_pagesize)
    _dl_pagesize = __getpagesize ();

is misleading -- __getpagesize() on Linux has no way to fetch the page
size apart from by reading _dl_pagesize.  This is not a problem for Linux
hosts that have a constant page size, which can simply use the PAGE_SIZE
macro, but MIPS/Linux is no longer one of them, so the new host-specific
version of __getpagesize() includes:

  assert (GL(dl_pagesize) != 0);

at the top.

 Now, getting back to the subject, please note that I am specifically
referring to the case when ld.so gets loaded as a result of dlopen() --
here's a small snippet that depicts what I mean:

#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
	void *h;
	int (*g)(void);
	int p0, p1;

	h = dlopen("/lib/libc.so.6", RTLD_GLOBAL | RTLD_LAZY);

	g = dlsym(h, "getpagesize");

	p0 = g();

	dlclose(h);

	p1 = getpagesize();

	printf("pagesize: %u, %u\n", p0, p1);

	return 0;
}

With glibc as distributed it outputs bad values of the page size.  With
glibc patched to add sysdeps/unix/sysv/linux/mips/getpagesize.c only, it
crashes due to the assertion quoted above.  While calling dlopen() on
libc.so isn't that useful itself, it corresponds to a real-life situation
when both libc.so and ld.so get loaded as a part of references to NSS
modules from static executables.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +


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