]> git.ipfire.org Git - thirdparty/glibc.git/blame - dlfcn/dladdr.c
elf: Refuse to dlopen PIE objects [BZ #24323]
[thirdparty/glibc.git] / dlfcn / dladdr.c
CommitLineData
a2b08ee5 1/* Locate the shared object symbol nearest a given address.
04277e02 2 Copyright (C) 1996-2019 Free Software Foundation, Inc.
afd4eb37 3 This file is part of the GNU C Library.
a2b934be 4
afd4eb37 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
a2b934be 9
afd4eb37
UD
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
a2b934be 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
a2b934be 18
a2b934be 19#include <dlfcn.h>
8e1472d2 20#include <ldsodefs.h>
a2b934be 21
9b42a0b3 22#if !defined SHARED && IS_IN (libdl)
5f21997b 23
a2b934be 24int
a2b08ee5 25dladdr (const void *address, Dl_info *info)
a2b934be 26{
5f21997b
UD
27 return __dladdr (address, info);
28}
29
30#else
31
32int
33__dladdr (const void *address, Dl_info *info)
34{
35# ifdef SHARED
8e1472d2 36 if (!rtld_active ())
5f21997b
UD
37 return _dlfcn_hook->dladdr (address, info);
38# endif
8dd56993 39 return _dl_addr (address, info, NULL, NULL);
a2b934be 40}
5f21997b
UD
41# ifdef SHARED
42strong_alias (__dladdr, dladdr)
43# endif
44#endif