]>
Commit | Line | Data |
---|---|---|
d66e34cd | 1 | /* Machine-dependent ELF dynamic relocation inline functions. Stub version. |
a334319f | 2 | Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc. |
47707456 | 3 | This file is part of the GNU C Library. |
d66e34cd | 4 | |
47707456 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
d66e34cd | 9 | |
47707456 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
d66e34cd | 14 | |
41bdb6e2 AJ |
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. */ | |
d66e34cd RM |
19 | |
20 | #define ELF_MACHINE_NAME "stub" | |
21 | ||
d66e34cd RM |
22 | #include <string.h> |
23 | #include <link.h> | |
24 | ||
25 | ||
ceb579a3 | 26 | /* Return nonzero iff ELF header is compatible with the running host. */ |
d66e34cd | 27 | static inline int |
ceb579a3 | 28 | elf_machine_matches_host (const Elf32_Ehdr *ehdr) |
d66e34cd | 29 | { |
ceb579a3 | 30 | switch (ehdr->e_machine) |
d66e34cd RM |
31 | { |
32 | default: | |
33 | return 0; | |
34 | } | |
35 | } | |
36 | ||
37 | ||
47707456 UD |
38 | /* Return the link-time address of _DYNAMIC. */ |
39 | static inline Elf32_Addr | |
40 | elf_machine_dynamic (void) | |
d66e34cd | 41 | { |
47707456 | 42 | #error "Damn, no _DYNAMIC" |
d66e34cd RM |
43 | } |
44 | ||
45 | ||
46 | /* Return the run-time load address of the shared object. */ | |
47 | static inline Elf32_Addr | |
48 | elf_machine_load_address (void) | |
49 | { | |
50 | #error "Where am I?" | |
51 | } | |
52 | ||
a2b08ee5 UD |
53 | /* Fixup a PLT entry to bounce directly to the function at VALUE. */ |
54 | ||
c0282c06 UD |
55 | static inline Elf32_Addr |
56 | elf_machine_fixup_plt (struct link_map *map, lookup_t t, | |
57 | const Elf32_Rel *reloc, | |
a2b08ee5 UD |
58 | Elf32_Addr *reloc_addr, Elf32_Addr value) |
59 | { | |
c0282c06 | 60 | return *reloc_addr = value; |
a2b08ee5 | 61 | } |
d66e34cd RM |
62 | |
63 | /* Perform the relocation specified by RELOC and SYM (which is fully resolved). | |
64 | LOADADDR is the load address of the object; INFO is an array indexed | |
65 | by DT_* of the .dynamic section info. */ | |
66 | ||
a334319f | 67 | static inline void |
d66e34cd | 68 | elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM], |
710f7bab RM |
69 | const Elf32_Rel *reloc, const Elf32_Sym *sym, |
70 | Elf32_Addr (*resolve) (const Elf32_Sym **ref, | |
71 | Elf32_Addr reloc_addr, | |
72 | int noplt)) | |
d66e34cd RM |
73 | { |
74 | Elf32_Addr *const reloc_addr = (Elf32_Addr *) reloc->r_offset; | |
710f7bab | 75 | Elf32_Addr loadbase; |
d66e34cd RM |
76 | |
77 | switch (ELF32_R_TYPE (reloc->r_info)) | |
78 | { | |
79 | case R_MACHINE_COPY: | |
710f7bab RM |
80 | loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); |
81 | memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size); | |
d66e34cd RM |
82 | break; |
83 | default: | |
421c80d2 | 84 | _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 0); |
d66e34cd RM |
85 | break; |
86 | } | |
87 | } | |
88 | ||
89 | ||
a334319f | 90 | static inline Elf32_Addr |
d66e34cd | 91 | elf_machine_rela (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM], |
710f7bab RM |
92 | const Elf32_Rel *reloc, const Elf32_Sym *sym, |
93 | Elf32_Addr (*resolve) (const Elf32_Sym **ref, | |
94 | Elf32_Addr reloc_addr, | |
95 | int noplt)) | |
d66e34cd RM |
96 | { |
97 | _dl_signal_error (0, "Elf32_Rela relocation requested -- unused on " | |
84aafa91 | 98 | NULL, ELF_MACHINE_NAME); |
d66e34cd RM |
99 | } |
100 | ||
101 | ||
102 | /* Set up the loaded object described by L so its unrelocated PLT | |
103 | entries will jump to the on-demand fixup code in dl-runtime.c. */ | |
104 | ||
0501d603 UD |
105 | static inline int |
106 | elf_machine_runtime_setup (struct link_map *l, int lazy) | |
d66e34cd RM |
107 | { |
108 | extern void _dl_runtime_resolve (Elf32_Word); | |
0501d603 | 109 | |
a2b08ee5 | 110 | if (lazy) |
0501d603 UD |
111 | { |
112 | /* The GOT entries for functions in the PLT have not yet been filled | |
113 | in. Their initial contents will arrange when called to push an | |
114 | offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1], | |
115 | and then jump to _GLOBAL_OFFSET_TABLE[2]. */ | |
a42195db | 116 | Elf32_Addr *got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); |
0501d603 UD |
117 | got[1] = (Elf32_Addr) l; /* Identify this shared object. */ |
118 | ||
119 | /* This function will get called to fix up the GOT entry indicated by | |
120 | the offset on the stack, and then jump to the resolved address. */ | |
121 | got[2] = (Elf32_Addr) &_dl_runtime_resolve; | |
122 | } | |
123 | ||
124 | return lazy; | |
d66e34cd RM |
125 | } |
126 | ||
127 | ||
128 | /* Initial entry point code for the dynamic linker. | |
129 | The C function `_dl_start' is the real entry point; | |
130 | its return value is the user program's entry point. */ | |
131 | ||
132 | #define RTLD_START #error need some startup code |