OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [dl/] [do-rel.h] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Do relocations for ELF dynamic linking.
2
   Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
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.
9
 
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.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
/* This file may be included twice, to define both
21
   `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.  */
22
 
23
#include <machine/weakalias.h>
24
 
25
#ifdef DO_RELA
26
# define elf_dynamic_do_rel             elf_dynamic_do_rela
27
# define RELCOUNT_IDX                   VERSYMIDX (DT_RELACOUNT)
28
# define Rel                            Rela
29
# define elf_machine_rel                elf_machine_rela
30
# define elf_machine_rel_relative       elf_machine_rela_relative
31
#else
32
# define RELCOUNT_IDX                   VERSYMIDX (DT_RELCOUNT)
33
#endif
34
 
35
#ifndef VERSYMIDX
36
# define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
37
#endif
38
 
39
/* Perform the relocations in MAP on the running program image as specified
40
   by RELTAG, SZTAG.  If LAZY is nonzero, this is the first pass on PLT
41
   relocations; they should be set up to call _dl_runtime_resolve, rather
42
   than fully resolved now.  */
43
 
44
static inline void
45
elf_dynamic_do_rel (struct link_map *map,
46
                    ElfW(Addr) reladdr, ElfW(Addr) relsize,
47
                    int lazy,
48
                    struct r_scope_elem *scope[])
49
{
50
  const ElfW(Rel) *r = (const void *) reladdr;
51
  const ElfW(Rel) *end = (const void *) (reladdr + relsize);
52
  ElfW(Addr) l_addr = map->l_addr;
53
 
54
#ifndef RTLD_BOOTSTRAP
55
  /* We never bind lazily during ld.so bootstrap.  Unfortunately gcc is
56
     not clever enough to see through all the function calls to realize
57
     that.  */
58
  if (lazy)
59
    {
60
      /* Doing lazy PLT relocations; they need very little info.  */
61
      for (; r < end; ++r)
62
        elf_machine_lazy_rel (map, l_addr, r);
63
    }
64
  else
65
#endif
66
    {
67
      const ElfW(Sym) *const symtab =
68
        (const void *) D_PTR (map, l_info[DT_SYMTAB]);
69
      ElfW(Word) nrelative = (map->l_info[RELCOUNT_IDX] == NULL
70
                              ? 0 : map->l_info[RELCOUNT_IDX]->d_un.d_val);
71
      const ElfW(Rel) *relative = r;
72
      r = MIN (r + nrelative, end);
73
 
74
#ifndef RTLD_BOOTSTRAP
75
      /* This is defined in rtld.c, but nowhere in the static libc.a; make
76
         the reference weak so static programs can still link.  This
77
         declaration cannot be done when compiling rtld.c (i.e. #ifdef
78
         RTLD_BOOTSTRAP) because rtld.c contains the common defn for
79
         _dl_rtld_map, which is incompatible with a weak decl in the same
80
         file.  */
81
      #pragma weak _dl_rtld_map
82
      if (map != &_dl_rtld_map) /* Already done in rtld itself.  */
83
# ifndef DO_RELA
84
        /* Rela platforms get the offset from r_addend and this must
85
           be copied in the relocation address.  Therefore we can skip
86
           the relative relocations only if this is for rel
87
           relocations.  */
88
        if (l_addr != 0)
89
# endif
90
#endif
91
          for (; relative < r; ++relative)
92
            elf_machine_rel_relative (l_addr, relative,
93
                                      (void *) (l_addr + relative->r_offset));
94
 
95
      if (map->l_info[VERSYMIDX (DT_VERSYM)])
96
        {
97
          const ElfW(Half) *const version =
98
            (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
99
 
100
          for (; r < end; ++r)
101
            {
102
              ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)];
103
              elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)],
104
                               &map->l_versions[ndx],
105
                               (void *) (l_addr + r->r_offset),
106
                               scope);
107
            }
108
        }
109
      else
110
        for (; r < end; ++r)
111
          elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL,
112
                           (void *) (l_addr + r->r_offset), scope);
113
    }
114
}
115
 
116
#undef elf_dynamic_do_rel
117
#undef Rel
118
#undef elf_machine_rel
119
#undef elf_machine_rel_relative
120
#undef RELCOUNT_IDX

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.