Back to index

glibc  2.9
dl-conflict.c
Go to the documentation of this file.
00001 /* Resolve conflicts against already prelinked libraries.
00002    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public License as
00008    published by the Free Software Foundation; either version 2.1 of the
00009    License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00018    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.  */
00020 
00021 #include <errno.h>
00022 #include <libintl.h>
00023 #include <stdlib.h>
00024 #include <unistd.h>
00025 #include <ldsodefs.h>
00026 #include <sys/mman.h>
00027 #include <sys/param.h>
00028 #include <sys/types.h>
00029 #include "dynamic-link.h"
00030 
00031 void
00032 _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
00033                      ElfW(Rela) *conflictend)
00034 {
00035 #if ! ELF_MACHINE_NO_RELA
00036   if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0))
00037     _dl_debug_printf ("\nconflict processing: %s\n",
00038                     l->l_name[0] ? l->l_name : rtld_progname);
00039 
00040   {
00041     /* Do the conflict relocation of the object and library GOT and other
00042        data.  */
00043 
00044     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
00045 #define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
00046 #define RESOLVE(ref, version, flags) (*ref = NULL, 0)
00047 #define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
00048   do {                                                               \
00049     while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset))             \
00050           || (resolve_conflict_map->l_map_start > (ElfW(Addr)) (r_offset)))  \
00051       resolve_conflict_map = resolve_conflict_map->l_next;                  \
00052                                                                      \
00053     (map) = resolve_conflict_map;                                    \
00054   } while (0)
00055 
00056     /* Prelinking makes no sense for anything but the main namespace.  */
00057     assert (l->l_ns == LM_ID_BASE);
00058     struct link_map *resolve_conflict_map __attribute__ ((__unused__))
00059       = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
00060 
00061 #include "dynamic-link.h"
00062 
00063     /* Override these, defined in dynamic-link.h.  */
00064 #undef CHECK_STATIC_TLS
00065 #define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0)
00066 #undef TRY_STATIC_TLS
00067 #define TRY_STATIC_TLS(ref_map, sym_map) (0)
00068 
00069     GL(dl_num_cache_relocations) += conflictend - conflict;
00070 
00071     for (; conflict < conflictend; ++conflict)
00072       elf_machine_rela (l, conflict, NULL, NULL, (void *) conflict->r_offset);
00073   }
00074 #endif
00075 }