This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix GL(dl_nns) updating in statically linked programs


Hi!

LC_ALL=ja_JP.UTF-8 ldconfig --help
just hangs,
LC_ALL=ja_JP ldconfig --help
prints:
ldconfig: dl-load.c:1962: _dl_map_object: Assertion `nsid < _dl_nns' �����Ԥ��ޤ���.
Aborted

The problem is the same, since the introduction of GL(dl_nns), if _dl_open
is called with __LM_ID_CALLER, but there are no shared libraries loaded at
all yet (GL(dl_nns) == 0, GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL), then
dl_open_worker sets args->nsid to LM_ID_BASE:
#ifndef SHARED
          /* In statically linked apps there might be no loaded object.  */
          if (call_map == NULL)
            args->nsid = LM_ID_BASE;
          else
#endif
but unlike calling _dl_open with LM_ID_BASE right away, GL(dl_nns) isn't set
to 1 and so dl-load.c assertion fails.

Fixed thusly, ok to commit?

2009-04-16  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-open.c (_dl_open): Bump GL(dl_nns) to 1 if no libraries
	are dlopened in statically linked program even for __LM_ID_CALLER.

--- libc/elf/dl-open.c.jj	2009-04-07 07:56:51.000000000 +0200
+++ libc/elf/dl-open.c	2009-04-16 12:25:16.000000000 +0200
@@ -580,7 +580,8 @@ no more namespaces available for dlmopen
     _dl_signal_error (EINVAL, file, NULL,
 		      N_("invalid target namespace in dlmopen()"));
 #ifndef SHARED
-  else if (nsid == LM_ID_BASE && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
+  else if ((nsid == LM_ID_BASE || nsid == __LM_ID_CALLER)
+	   && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
 	   && GL(dl_nns) == 0)
     GL(dl_nns) = 1;
 #endif


	Jakub


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