/* Look up a symbol in the loaded objects.
Copyright (C) 1995-2025 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
<https://www.gnu.org/licenses/>. */
#include <libintl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ldsodefs.h>
#include <dl-hash.h>
#include <dl-machine.h>
#include <dl-new-hash.h>
#include <dl-protected.h>
#include <sysdep-cancel.h>
#include <libc-lock.h>
#include <tls.h>
#include <atomic.h>
#include <elf_machine_sym_no_match.h>
#include <assert.h>
#define VERSTAG(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
struct sym_val
{
const ElfW(Sym) *s;
struct link_map *m;
};
/* Statistics function. */
#ifdef SHARED
# define bump_num_relocations() ++GL(dl_num_relocations)
#else
# define bump_num_relocations() ((void) 0)
#endif
/* Utility function for do_lookup_x. The caller is called with undef_name,
ref, version, flags and type_class, and those are passed as the first
five arguments. The caller then computes sym, symidx, strtab, and map
and passes them as the next four arguments. Lastly the caller passes in
versioned_sym and num_versions which are modified by check_match during
the checking process. */
static const ElfW(Sym) *
check_match (const char *const undef_name,
const ElfW(Sym) *const ref,
const struct r_found_version *const version,
const int flags,
const int type_class,
const ElfW(Sym) *const sym,
const Elf_Symndx symidx,
const char *const strtab,
const struct link_map *const map,
const ElfW(Sym) **const versioned_sym,
int *const num_versions)
{
unsigned int