]>
sourceware.org Git - glibc.git/blob - elf/dynamic-link.h
fc5c585356d776d5e57e0a047c11b5a0e63ed20e
1 /* Inline functions for 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. */
21 #include <dl-machine.h>
25 /* Read the dynamic section at DYN and fill in INFO with indices DT_*. */
28 elf_get_dynamic_info (Elf32_Dyn
*dyn
, Elf32_Dyn
*info
[DT_NUM
])
32 for (i
= 0; i
< DT_NUM
; ++i
)
35 while (dyn
->d_tag
!= DT_NULL
)
37 assert (dyn
->d_tag
< DT_NUM
);
38 info
[dyn
->d_tag
] = dyn
++;
42 assert (info
[DT_RELAENT
]->d_un
.d_val
== sizeof (Elf32_Rela
));
44 assert (info
[DT_RELENT
]->d_un
.d_val
== sizeof (Elf32_Rel
));
46 assert (info
[DT_PLTREL
]->d_un
.d_val
== DT_REL
||
47 info
[DT_PLTREL
]->d_un
.d_val
== DT_RELA
);
50 /* Get the definitions of `elf_dynamic_do_rel' and `elf_dynamic_do_rela'.
51 These functions are almost identical, so we use cpp magic to avoid
52 duplicating their code. It cannot be done in a more general function
53 because we must be able to completely inline. */
55 #if ! ELF_MACHINE_NO_REL
57 #define ELF_DYNAMIC_DO_REL(map, lazy, resolve) \
58 if ((map)->l_info[DT_REL]) \
59 elf_dynamic_do_rel ((map), DT_REL, DT_RELSZ, (resolve)); \
60 if (!(lazy) && (map)->l_info[DT_PLTREL]->d_un.d_val == DT_REL) \
61 elf_dynamic_do_rel ((map), DT_JMPREL, DT_PLTRELSZ, (resolve));
63 #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) /* Nothing to do. */
66 #if ! ELF_MACHINE_NO_RELA
69 #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) \
70 if ((map)->l_info[DT_RELA]) \
71 elf_dynamic_do_rela ((map), DT_RELA, DT_RELASZ, (resolve)); \
72 if (!(lazy) && (map)->l_info[DT_PLTREL]->d_un.d_val == DT_RELA) \
73 elf_dynamic_do_rela ((map), DT_JMPREL, DT_PLTRELSZ, (resolve);
75 #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) /* Nothing to do. */
78 /* This can't just be an inline function because GCC is too dumb
79 to inline functions containing inlines themselves. */
80 #define ELF_DYNAMIC_RELOCATE(map, lazy, resolve) \
81 do { ELF_DYNAMIC_DO_REL ((map), (lazy), (resolve)); \
82 ELF_DYNAMIC_DO_RELA ((map), (lazy), (resolve)); } while (0)
This page took 0.041351 seconds and 4 git commands to generate.