This is the mail archive of the libc-alpha@sourceware.org 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]

[RFC][BZ #16046] dl_iterate_phdr should not expose internal stub.


Hi,

A dl_iterate_phdr has following output which was taken from bugzilla.

Using current git trunk, dynamically linked binary shows:

addr=(nil) name= phdr=0x400040 phnum=9
addr=0x7fff2a613000 name=linux-vdso.so.1 phdr=0x7fff29d13040 phnum=4
addr=0x7f73a76d4000 name=./libc.so.6 phdr=0x7f73a76d4040 phnum=10
addr=0x7f73a7a87000 name=./elf/ld.so phdr=0x7f73a7a87040 phnum=7

Statically linked binary:

addr=(nil) name= phdr=0x400040 phnum=6
addr=(nil) name= phdr=(nil) phnum=0
addr=0x7ffffd5e1000 name=linux-vdso.so.1 phdr=0x7ffffcce1040 phnum=4

AFAICT, this was added in commit:

 commit f91f1c0fb89056995f1c9c6a06c361efdf5139e7
 Author: Maciej W. Rozycki <macro@codesourcery.com>
 Date:   Fri Jun 28 16:20:26 2013 +0100

    [BZ #15022] Correct global-scope dlopen issues in static executables.
    
    This change creates a link map in static executables to serve as the
    global search list for dlopen.  It fixes a problem with the inability
    to access the global symbol object and a crash on an attempt to map a
    DSO into the global scope.  Some code that has become dead after the
    addition of this link map is removed too and test cases are provided.



A fix should be easy with proper knowledge. It should look like following one,
but I am not completely sure if it suffices to check if phdr is nonnul.

Comments?

	[BZ #16046]
	* elf/dl-iteratephdr.c: Hide internal stub.

diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 609b900..928e76c 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -63,6 +63,8 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 
   for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)
     {
+      if (l->l_real->l_phdr == NULL) /* Ignore static executable link map.  */
+        continue;
       info.dlpi_addr = l->l_real->l_addr;
       info.dlpi_name = l->l_real->l_name;
       info.dlpi_phdr = l->l_real->l_phdr;


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