1 /* Resolve conflicts against already prelinked libraries.
2 Copyright (C) 2001-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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 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; see the file COPYING.LIB. If
17 not, see <https://www.gnu.org/licenses/>. */
25 #include <sys/param.h>
26 #include <sys/types.h>
27 #include "dynamic-link.h"
30 _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
31 ElfW(Rela) *conflictend)
33 #if ! ELF_MACHINE_NO_RELA
34 if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC))
35 _dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name));
38 /* Do the conflict relocation of the object and library GOT and other
41 /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
42 #define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
43 #define RESOLVE(ref, version, flags) (*ref = NULL, 0)
44 #define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
46 while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \
47 || (resolve_conflict_map->l_map_start > (ElfW(Addr)) (r_offset))) \
48 resolve_conflict_map = resolve_conflict_map->l_next; \
50 (map) = resolve_conflict_map; \
53 /* Prelinking makes no sense for anything but the main namespace. */
54 assert (l->l_ns == LM_ID_BASE);
55 struct link_map *resolve_conflict_map __attribute__ ((__unused__))
56 = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
58 #include "dynamic-link.h"
60 /* Override these, defined in dynamic-link.h. */
61 #undef CHECK_STATIC_TLS
62 #define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0)
64 #define TRY_STATIC_TLS(ref_map, sym_map) (0)
66 GL(dl_num_cache_relocations) += conflictend - conflict;
68 for (; conflict < conflictend; ++conflict)
69 elf_machine_rela (l, conflict, NULL, NULL, (void *) conflict->r_offset,