]>
Commit | Line | Data |
---|---|---|
acdcca72 | 1 | /* On-demand PLT fixup for shared objects. HPPA version. |
2b778ceb | 2 | Copyright (C) 2019-2021 Free Software Foundation, Inc. |
acdcca72 JDA |
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 | ||
acdcca72 JDA |
20 | #include <elf/dl-runtime.c> |
21 | ||
22 | /* The caller has encountered a partially relocated function descriptor. | |
23 | The gp of the descriptor has been updated, but not the ip. We find | |
24 | the function descriptor again and compute the relocation offset and | |
25 | return that to the caller. The caller will continue on to call | |
26 | _dl_fixup with the relocation offset. */ | |
27 | ||
28 | ElfW(Word) | |
29 | attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE | |
30 | _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l) | |
31 | { | |
32 | Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type; | |
33 | const Elf32_Rela *reloc; | |
34 | ||
35 | l_addr = l->l_addr; | |
36 | jmprel = D_PTR(l, l_info[DT_JMPREL]); | |
37 | end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val; | |
38 | ||
39 | /* Look for the entry... */ | |
40 | for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela)) | |
41 | { | |
42 | reloc = (const Elf32_Rela *) iplt; | |
43 | r_type = ELF32_R_TYPE (reloc->r_info); | |
44 | ||
45 | if (__builtin_expect (r_type == R_PARISC_IPLT, 1) | |
46 | && fptr == (struct fdesc *) (reloc->r_offset + l_addr)) | |
47 | /* Found entry. Return the reloc offset. */ | |
48 | return iplt - jmprel; | |
49 | } | |
50 | ||
51 | /* Crash if we weren't passed a valid function pointer. */ | |
52 | ABORT_INSTRUCTION; | |
53 | return 0; | |
54 | } |