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'. */
24 #define elf_dynamic_do_rel elf_dynamic_do_rela
25 #define Elf32_Rel Elf32_Rela
26 #define elf_machine_rel elf_machine_rela
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. */
38 elf_dynamic_do_rel (struct link_map
*map
,
39 int reltag
, int sztag
,
40 Elf32_Addr (*resolve
) (const Elf32_Sym
**symbol
,
44 const Elf32_Sym
*const symtab
45 = (const Elf32_Sym
*) (map
->l_addr
+ map
->l_info
[DT_SYMTAB
]->d_un
.d_ptr
);
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
];
51 /* Doing lazy PLT relocations; they need very little info. */
53 elf_machine_lazy_rel (map
, r
);
57 const Elf32_Sym
*definer
= &symtab
[ELF32_R_SYM (r
->r_info
)];
60 if (ELF32_R_SYM (r
->r_info
) == STN_UNDEF
)
61 loadbase
= 0; /* This value will not be consulted. */
65 loadbase
= (*resolve
) (&definer
, r
->r_offset
);
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
78 #undef elf_machine_rel