]>
sourceware.org Git - glibc.git/blob - elf/do-rel.h
04643e8facbda672db997ba8fda85855a85ac281
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. */
36 elf_dynamic_do_rel (struct link_map
*map
,
37 int reltag
, int sztag
,
38 Elf32_Addr (*resolve
) (const Elf32_Sym
**))
40 const Elf32_Sym
*const symtab
41 = (const Elf32_Sym
*) map
->l_info
[DT_SYMTAB
]->d_un
.d_ptr
;
42 const Elf32_Rel
*r
= (const Elf32_Rel
*) map
->l_info
[reltag
]->d_un
.d_ptr
;
43 const Elf32_Rel
*end
= &r
[map
->l_info
[sztag
]->d_un
.d_val
/ sizeof *r
];
47 const Elf32_Sym
*definer
= &symtab
[ELF32_R_SYM (r
->r_info
)];
50 if (ELF32_R_SYM (r
->r_info
) == STN_UNDEF
)
51 loadbase
= 0; /* This value will not be consulted. */
55 loadbase
= (*resolve
) (&definer
);
58 assert (definer
->st_shndx
!= SHN_UNDEF
);
59 loadbase
= map
->l_addr
;
62 elf_machine_rel (map
, r
, loadbase
, definer
);
66 #undef elf_dynamic_do_rel
68 #undef elf_machine_rel
This page took 0.038487 seconds and 4 git commands to generate.