Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / powerpc64 / ldsodefs.h
blob491db8f71969c68d04568945e5f473fe1456eabe
1 /* Run-time dynamic linker data structures for loaded ELF shared objects.
2 Copyright (C) 2005-2014 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 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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LDSODEFS_H
21 /* Get the real definitions. */
22 #include_next <ldsodefs.h>
24 /* Now define our stuff. */
26 #if _CALL_ELF != 2
28 static __always_inline bool
29 _dl_ppc64_is_opd_sym (const struct link_map *l, const ElfW(Sym) *sym)
31 return (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
32 && l->l_addr + sym->st_value >= (ElfW(Addr)) l->l_ld
33 && l->l_addr + sym->st_value < l->l_map_end
34 && sym->st_size != 0);
37 static __always_inline bool
38 _dl_ppc64_addr_sym_match (const struct link_map *l, const ElfW(Sym) *sym,
39 const ElfW(Sym) *matchsym, ElfW(Addr) addr)
41 ElfW(Addr) value = l->l_addr + sym->st_value;
42 if (_dl_ppc64_is_opd_sym (l, sym))
44 if (addr < value || addr >= value + 24)
46 value = *(ElfW(Addr) *) value;
47 if (addr < value || addr >= value + sym->st_size)
48 return false;
51 else if (sym->st_shndx == SHN_UNDEF || sym->st_size == 0)
53 if (addr != value)
54 return false;
56 else if (addr < value || addr >= value + sym->st_size)
57 return false;
59 if (matchsym == NULL)
60 return true;
62 ElfW(Addr) matchvalue = l->l_addr + matchsym->st_value;
63 if (_dl_ppc64_is_opd_sym (l, matchsym)
64 && (addr < matchvalue || addr > matchvalue + 24))
65 matchvalue = *(ElfW(Addr) *) matchvalue;
67 return matchvalue < value;
70 /* If this is a function symbol defined past the end of our dynamic
71 section, then it must be a function descriptor. Allow these symbols
72 to match their associated function code range as well as the
73 descriptor addresses. */
74 #undef DL_ADDR_SYM_MATCH
75 #define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \
76 _dl_ppc64_addr_sym_match (L, SYM, MATCHSYM, ADDR)
78 #endif
80 #endif /* ldsodefs.h */