| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Resolve conflicts against already prelinked libraries. | 
 | 2 |    Copyright (C) 2001-2016 Free Software Foundation, Inc. | 
 | 3 |    This file is part of the GNU C Library. | 
 | 4 |    Contributed by Jakub Jelinek <jakub@redhat.com>, 2001. | 
 | 5 |  | 
 | 6 |    The GNU C Library is free software; you can redistribute it and/or | 
 | 7 |    modify it under the terms of the GNU Lesser General Public License as | 
 | 8 |    published by the Free Software Foundation; either version 2.1 of the | 
 | 9 |    License, or (at your option) any later version. | 
 | 10 |  | 
 | 11 |    The GNU C Library is distributed in the hope that it will be useful, | 
 | 12 |    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 13 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
 | 14 |    Lesser General Public License for more details. | 
 | 15 |  | 
 | 16 |    You should have received a copy of the GNU Lesser General Public | 
 | 17 |    License along with the GNU C Library; see the file COPYING.LIB.  If | 
 | 18 |    not, see <http://www.gnu.org/licenses/>.  */ | 
 | 19 |  | 
 | 20 | #include <errno.h> | 
 | 21 | #include <libintl.h> | 
 | 22 | #include <stdlib.h> | 
 | 23 | #include <unistd.h> | 
 | 24 | #include <ldsodefs.h> | 
 | 25 | #include <sys/mman.h> | 
 | 26 | #include <sys/param.h> | 
 | 27 | #include <sys/types.h> | 
 | 28 | #include "dynamic-link.h" | 
 | 29 |  | 
 | 30 | void | 
 | 31 | _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict, | 
 | 32 | 		       ElfW(Rela) *conflictend) | 
 | 33 | { | 
 | 34 | #if ! ELF_MACHINE_NO_RELA | 
 | 35 |   if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_RELOC)) | 
 | 36 |     _dl_debug_printf ("\nconflict processing: %s\n", DSO_FILENAME (l->l_name)); | 
 | 37 |  | 
 | 38 |   { | 
 | 39 |     /* Do the conflict relocation of the object and library GOT and other | 
 | 40 |        data.  */ | 
 | 41 |  | 
 | 42 |     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */ | 
 | 43 | #define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL) | 
 | 44 | #define RESOLVE(ref, version, flags) (*ref = NULL, 0) | 
 | 45 | #define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \ | 
 | 46 |   do {									      \ | 
 | 47 |     while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset))	      \ | 
 | 48 | 	   || (resolve_conflict_map->l_map_start > (ElfW(Addr)) (r_offset)))  \ | 
 | 49 |       resolve_conflict_map = resolve_conflict_map->l_next;		      \ | 
 | 50 | 									      \ | 
 | 51 |     (map) = resolve_conflict_map;					      \ | 
 | 52 |   } while (0) | 
 | 53 |  | 
 | 54 |     /* Prelinking makes no sense for anything but the main namespace.  */ | 
 | 55 |     assert (l->l_ns == LM_ID_BASE); | 
 | 56 |     struct link_map *resolve_conflict_map __attribute__ ((__unused__)) | 
 | 57 |       = GL(dl_ns)[LM_ID_BASE]._ns_loaded; | 
 | 58 |  | 
 | 59 | #include "dynamic-link.h" | 
 | 60 |  | 
 | 61 |     /* Override these, defined in dynamic-link.h.  */ | 
 | 62 | #undef CHECK_STATIC_TLS | 
 | 63 | #define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0) | 
 | 64 | #undef TRY_STATIC_TLS | 
 | 65 | #define TRY_STATIC_TLS(ref_map, sym_map) (0) | 
 | 66 |  | 
 | 67 |     GL(dl_num_cache_relocations) += conflictend - conflict; | 
 | 68 |  | 
 | 69 |     for (; conflict < conflictend; ++conflict) | 
 | 70 |       elf_machine_rela (l, conflict, NULL, NULL, (void *) conflict->r_offset, | 
 | 71 | 			0); | 
 | 72 |   } | 
 | 73 | #endif | 
 | 74 | } |