* time/tzfile.h, time/private.h, time/zdump.c, time/zic.c,
[glibc.git] / elf / do-rel.h
blob438613a32d71f49dc7b56bb14169d3aeee04df88
1 /* Do relocations for ELF dynamic linking.
2 Copyright (C) 1995, 1996 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 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.
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.
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
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 /* This file may be included twice, to define both
21 `elf_dynamic_do_rel' and `elf_dynamic_do_rela'. */
23 #ifdef DO_RELA
24 #define elf_dynamic_do_rel elf_dynamic_do_rela
25 #define Elf32_Rel Elf32_Rela
26 #define elf_machine_rel elf_machine_rela
27 #endif
30 /* Perform the relocations in MAP on the running program image as specified
31 by RELTAG, SZTAG. *RESOLVE is called to resolve symbol values; it
32 modifies its argument pointer to point to the defining symbol, and
33 returns the base load address of the defining object. If LAZY is
34 nonzero, this is the first pass on PLT relocations; they should be set
35 up to call _dl_runtime_resolve, rather than fully resolved now. */
37 static inline void
38 elf_dynamic_do_rel (struct link_map *map,
39 int reltag, int sztag,
40 Elf32_Addr (*resolve) (const Elf32_Sym **symbol,
41 Elf32_Addr reloc_addr, int noplt),
42 int lazy)
44 const Elf32_Sym *const symtab
45 = (const Elf32_Sym *) (map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr);
46 const Elf32_Rel *r
47 = (const Elf32_Rel *) (map->l_addr + map->l_info[reltag]->d_un.d_ptr);
48 const Elf32_Rel *end = &r[map->l_info[sztag]->d_un.d_val / sizeof *r];
50 if (lazy)
51 /* Doing lazy PLT relocations; they need very little info. */
52 for (; r < end; ++r)
53 elf_machine_lazy_rel (map, r);
54 else
55 for (; r < end; ++r)
56 elf_machine_rel (map, r, &symtab[ELF32_R_SYM (r->r_info)], resolve);
59 #undef elf_dynamic_do_rel
60 #undef Elf32_Rel
61 #undef elf_machine_rel