]>
Commit | Line | Data |
---|---|---|
421f82e5 | 1 | /* Do relocations for ELF dynamic linking. |
c84142e8 | 2 | Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
afd4eb37 | 3 | This file is part of the GNU C Library. |
421f82e5 | 4 | |
afd4eb37 UD |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
421f82e5 | 9 | |
afd4eb37 UD |
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 | Library General Public License for more details. | |
421f82e5 | 14 | |
afd4eb37 UD |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
421f82e5 RM |
19 | |
20 | /* This file may be included twice, to define both | |
21 | `elf_dynamic_do_rel' and `elf_dynamic_do_rela'. */ | |
22 | ||
23 | #ifdef DO_RELA | |
c84142e8 UD |
24 | # define elf_dynamic_do_rel elf_dynamic_do_rela |
25 | # define Rel Rela | |
26 | # define elf_machine_rel elf_machine_rela | |
421f82e5 RM |
27 | #endif |
28 | ||
c84142e8 UD |
29 | #ifndef VERSYMIDX |
30 | # define VERSYMIDX(sym) (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (sym)) | |
31 | #endif | |
421f82e5 RM |
32 | |
33 | /* Perform the relocations in MAP on the running program image as specified | |
f51d1dfd RM |
34 | by RELTAG, SZTAG. If LAZY is nonzero, this is the first pass on PLT |
35 | relocations; they should be set up to call _dl_runtime_resolve, rather | |
36 | than fully resolved now. */ | |
421f82e5 RM |
37 | |
38 | static inline void | |
39 | elf_dynamic_do_rel (struct link_map *map, | |
d94d8f2a | 40 | int reltag, int sztag, |
a1a9d215 | 41 | int lazy) |
421f82e5 | 42 | { |
266180eb RM |
43 | const ElfW(Rel) *r |
44 | = (const ElfW(Rel) *) (map->l_addr + map->l_info[reltag]->d_un.d_ptr); | |
45 | const ElfW(Rel) *end = &r[map->l_info[sztag]->d_un.d_val / sizeof *r]; | |
421f82e5 | 46 | |
a1a9d215 RM |
47 | if (lazy) |
48 | /* Doing lazy PLT relocations; they need very little info. */ | |
49 | for (; r < end; ++r) | |
50 | elf_machine_lazy_rel (map, r); | |
51 | else | |
c84142e8 UD |
52 | { |
53 | const ElfW(Sym) *const symtab = | |
54 | (const ElfW(Sym) *) (map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr); | |
55 | ||
56 | if (map->l_info[VERSYMIDX (DT_VERNEEDNUM)]) | |
57 | { | |
58 | const ElfW(Half) *const version = | |
59 | (const ElfW(Half) *) (map->l_addr | |
60 | + map->l_info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr); | |
61 | ||
62 | for (; r < end; ++r) | |
63 | { | |
64 | ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)]; | |
65 | elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], | |
66 | &map->l_versions[ndx]); | |
67 | } | |
68 | } | |
69 | else | |
70 | for (; r < end; ++r) | |
71 | elf_machine_rel (map, r, &symtab[ELFW(R_SYM) (r->r_info)], NULL); | |
72 | } | |
421f82e5 RM |
73 | } |
74 | ||
75 | #undef elf_dynamic_do_rel | |
266180eb | 76 | #undef Rel |
421f82e5 | 77 | #undef elf_machine_rel |