chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / sysdeps / unix / sysv / linux / powerpc / powerpc64 / ldsodefs.h
1 /* Run-time dynamic linker data structures for loaded ELF shared objects.
2    Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
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    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #ifndef _LDSODEFS_H
21
22 /* Get the real definitions.  */
23 #include_next <ldsodefs.h>
24
25 /* Now define our stuff.  */
26
27 static __always_inline bool
28 _dl_ppc64_is_opd_sym (const struct link_map *l, const ElfW(Sym) *sym)
29 {
30   return (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
31           && l->l_addr + sym->st_value >= (ElfW(Addr)) l->l_ld
32           && l->l_addr + sym->st_value < l->l_map_end
33           && sym->st_size != 0);
34 }
35
36 static __always_inline bool
37 _dl_ppc64_addr_sym_match (const struct link_map *l, const ElfW(Sym) *sym,
38                           const ElfW(Sym) *matchsym, ElfW(Addr) addr)
39 {
40   ElfW(Addr) value = l->l_addr + sym->st_value;
41   if (_dl_ppc64_is_opd_sym (l, sym))
42     {
43       if (addr < value || addr >= value + 24)
44         {
45           value = *(ElfW(Addr) *) value;
46           if (addr < value || addr >= value + sym->st_size)
47             return false;
48         }
49     }
50   else if (sym->st_shndx == SHN_UNDEF || sym->st_size == 0)
51     {
52       if (addr != value)
53         return false;
54     }
55   else if (addr < value || addr >= value + sym->st_size)
56     return false;
57
58   if (matchsym == NULL)
59     return true;
60
61   ElfW(Addr) matchvalue = l->l_addr + matchsym->st_value;
62   if (_dl_ppc64_is_opd_sym (l, matchsym)
63       && (addr < matchvalue || addr > matchvalue + 24))
64     matchvalue = *(ElfW(Addr) *) matchvalue;
65
66   return matchvalue < value;
67 }
68
69 /* If this is a function symbol defined past the end of our dynamic
70    section, then it must be a function descriptor.  Allow these symbols
71    to match their associated function code range as well as the
72    descriptor addresses.  */
73 #undef DL_ADDR_SYM_MATCH
74 #define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \
75   _dl_ppc64_addr_sym_match (L, SYM, MATCHSYM, ADDR)
76
77 #endif /* ldsodefs.h */