1 /* Post-processing of a symbol produced by dlsym, dlvsym.
2 Copyright (C) 1999-2023 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/>. */
20 /* Return the link map containing the caller address. */
21 static struct link_map
*
22 _dl_sym_find_caller_link_map (ElfW(Addr
) caller
)
24 struct link_map
*l
= _dl_find_dso_for_object (caller
);
28 /* If the address is not recognized the call comes from the main
30 return GL(dl_ns
)[LM_ID_BASE
]._ns_loaded
;
33 /* Translates RESULT, *REF, VALUE into a symbol address from the point
34 of view of MATCH. Performs IFUNC resolution and auditing if
35 necessary. If MATCH is NULL, CALLER is used to determine it. */
37 _dl_sym_post (lookup_t result
, const ElfW(Sym
) *ref
, void *value
,
38 ElfW(Addr
) caller
, struct link_map
*match
)
40 /* Resolve indirect function address. */
41 if (__glibc_unlikely (ELFW(ST_TYPE
) (ref
->st_info
) == STT_GNU_IFUNC
))
43 DL_FIXUP_VALUE_TYPE fixup
44 = DL_FIXUP_MAKE_VALUE (result
, (ElfW(Addr
)) value
);
45 fixup
= elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (fixup
));
46 value
= (void *) DL_FIXUP_VALUE_CODE_ADDR (fixup
);
50 /* Auditing checkpoint: we have a new binding. Provide the
51 auditing libraries the possibility to change the value and
52 tell us whether further auditing is wanted. */
53 if (__glibc_unlikely (GLRO(dl_naudit
) > 0))
56 match
= _dl_sym_find_caller_link_map (caller
);
57 _dl_audit_symbind_alt (match
, ref
, &value
, result
);