(__setgid): Switch the port-type and port-count parameters to __auth_makeauth.
[glibc.git] / elf / do-rel.h
blob9657bc2297a6ed1045398ec091d5928d4941cae0
1 /* Do relocations for ELF dynamic linking.
2 Copyright (C) 1995 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 r_offset),
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)
57 const Elf32_Sym *definer = &symtab[ELF32_R_SYM (r->r_info)];
58 Elf32_Addr loadbase;
60 if (ELF32_R_SYM (r->r_info) == STN_UNDEF)
61 loadbase = 0; /* This value will not be consulted. */
62 else
64 if (resolve)
65 loadbase = (*resolve) (&definer, r->r_offset);
66 else
68 assert (definer->st_shndx != SHN_UNDEF);
69 loadbase = map->l_addr;
72 elf_machine_rel (map, r, loadbase, definer);
76 #undef elf_dynamic_do_rel
77 #undef Elf32_Rel
78 #undef elf_machine_rel