about summary refs log tree commit diff
path: root/elf/tst-dlopen-aout-container.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-08-15 14:37:50 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-08-15 18:53:32 +0200
commit23d2e5faf0bca6d9b31bef4aa162b95ee64cbfc6 (patch)
tree11fc805f477834891503dcf35ba52d183b71d0d5 /elf/tst-dlopen-aout-container.c
parent42760d764649ad82f5fe45a26cbdf2c2500409f7 (diff)
downloadglibc-23d2e5faf0bca6d9b31bef4aa162b95ee64cbfc6.tar.gz
glibc-23d2e5faf0bca6d9b31bef4aa162b95ee64cbfc6.tar.xz
glibc-23d2e5faf0bca6d9b31bef4aa162b95ee64cbfc6.zip
elf: Self-dlopen failure with explict loader invocation [BZ #24900]
In case of an explicit loader invocation, ld.so essentially performs
a dlopen call to load the main executable.  Since the pathname of
the executable is known at this point, it gets stored in the link
map.  In regular mode, the pathname is not known and "" is used
instead.

As a result, if a program calls dlopen on the pathname of the main
program, the dlopen call succeeds and returns a handle for the main
map.  This results in an unnecessary difference between glibc
testing (without --enable-hardcoded-path-in-tests) and production
usage.

This commit discards the names when building the link map in
_dl_new_object for the main executable, but it still determines
the origin at this point in case of an explict loader invocation.
The reason is that the specified pathname has to be used; the kernel
has a different notion of the main executable.
Diffstat (limited to 'elf/tst-dlopen-aout-container.c')
-rw-r--r--elf/tst-dlopen-aout-container.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/elf/tst-dlopen-aout-container.c b/elf/tst-dlopen-aout-container.c
new file mode 100644
index 0000000000..9b9f86133d
--- /dev/null
+++ b/elf/tst-dlopen-aout-container.c
@@ -0,0 +1,19 @@
+/* Test case for BZ #16634 and BZ#24900.  Container version.
+   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "tst-dlopen-aout.c"