1 /* Partial initialization of ld.so loaded via static dlopen.
2 Copyright (C) 2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 /* Very special case: This object is built into the static libc, but
22 must know the layout of _rtld_global_ro. */
26 #include <rtld_static_init.h>
28 static const struct dlfcn_hook _dlfcn_hook
=
39 .libc_dlopen_mode
= __libc_dlopen_mode
,
40 .libc_dlsym
= __libc_dlsym
,
41 .libc_dlvsym
= __libc_dlvsym
,
42 .libc_dlclose
= __libc_dlclose
,
46 __rtld_static_init (struct link_map
*map
)
49 = _dl_lookup_direct (map
, "_rtld_global_ro",
50 0x9f28436a, /* dl_new_hash output. */
52 0x0963cf85); /* _dl_elf_hash output. */
54 struct rtld_global_ro
*dl
= DL_SYMBOL_ADDRESS (map
, sym
);
56 /* Perform partial initialization here. Note that this runs before
57 ld.so is relocated, so only members initialized without
58 relocations can be written here. */
59 #ifdef HAVE_AUX_VECTOR
60 extern __typeof (dl
->_dl_auxv
) _dl_auxv attribute_hidden
;
61 dl
->_dl_auxv
= _dl_auxv
;
62 extern __typeof (dl
->_dl_clktck
) _dl_clktck attribute_hidden
;
63 dl
->_dl_clktck
= _dl_clktck
;
65 dl
->_dl_dlfcn_hook
= &_dlfcn_hook
;
66 extern __typeof (dl
->_dl_hwcap
) _dl_hwcap attribute_hidden
;
67 dl
->_dl_hwcap
= _dl_hwcap
;
68 extern __typeof (dl
->_dl_hwcap2
) _dl_hwcap2 attribute_hidden
;
69 dl
->_dl_hwcap2
= _dl_hwcap2
;
70 extern __typeof (dl
->_dl_minsigstacksize
) _dl_minsigstacksize
72 dl
->_dl_minsigstacksize
= _dl_minsigstacksize
;
73 extern __typeof (dl
->_dl_pagesize
) _dl_pagesize attribute_hidden
;
74 dl
->_dl_pagesize
= _dl_pagesize
;
75 extern __typeof (dl
->_dl_tls_static_align
) _dl_tls_static_align
77 dl
->_dl_tls_static_align
= _dl_tls_static_align
;
78 extern __typeof (dl
->_dl_tls_static_size
) _dl_tls_static_size
80 dl
->_dl_tls_static_size
= _dl_tls_static_size
;
82 __rtld_static_init_arch (map
, dl
);