Deleted Added
full compact
elf_machdep.c (105469) elf_machdep.c (109605)
1/*-
2 * Copyright 1996-1998 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
1/*-
2 * Copyright 1996-1998 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/i386/i386/elf_machdep.c 105469 2002-10-19 19:16:03Z marcel $
25 * $FreeBSD: head/sys/i386/i386/elf_machdep.c 109605 2003-01-21 02:42:44Z jake $
26 */
27
28#include <sys/param.h>
29#include <sys/kernel.h>
30#include <sys/systm.h>
31#include <sys/exec.h>
32#include <sys/imgact.h>
33#include <sys/linker.h>

--- 47 unchanged lines hidden (view full) ---

81 &elf32_freebsd_sysvec
82 };
83
84SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
85 (sysinit_cfunc_t) elf32_insert_brand_entry,
86 &freebsd_brand_info);
87
88/* Process one elf relocation with addend. */
26 */
27
28#include <sys/param.h>
29#include <sys/kernel.h>
30#include <sys/systm.h>
31#include <sys/exec.h>
32#include <sys/imgact.h>
33#include <sys/linker.h>

--- 47 unchanged lines hidden (view full) ---

81 &elf32_freebsd_sysvec
82 };
83
84SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
85 (sysinit_cfunc_t) elf32_insert_brand_entry,
86 &freebsd_brand_info);
87
88/* Process one elf relocation with addend. */
89int
90elf_reloc(linker_file_t lf, const void *data, int type)
89static int
90elf_reloc_internal(linker_file_t lf, const void *data, int type, int local)
91{
92 Elf_Addr relocbase = (Elf_Addr) lf->address;
93 Elf_Addr *where;
94 Elf_Addr addr;
95 Elf_Addr addend;
96 Elf_Word rtype, symidx;
97 const Elf_Rel *rel;
98 const Elf_Rela *rela;

--- 12 unchanged lines hidden (view full) ---

111 addend = rela->r_addend;
112 rtype = ELF_R_TYPE(rela->r_info);
113 symidx = ELF_R_SYM(rela->r_info);
114 break;
115 default:
116 panic("unknown reloc type %d\n", type);
117 }
118
91{
92 Elf_Addr relocbase = (Elf_Addr) lf->address;
93 Elf_Addr *where;
94 Elf_Addr addr;
95 Elf_Addr addend;
96 Elf_Word rtype, symidx;
97 const Elf_Rel *rel;
98 const Elf_Rela *rela;

--- 12 unchanged lines hidden (view full) ---

111 addend = rela->r_addend;
112 rtype = ELF_R_TYPE(rela->r_info);
113 symidx = ELF_R_SYM(rela->r_info);
114 break;
115 default:
116 panic("unknown reloc type %d\n", type);
117 }
118
119 if (local) {
120 if (rtype == R_386_RELATIVE) { /* A + B */
121 addr = relocbase + addend;
122 if (*where != addr)
123 *where = addr;
124 }
125 return (0);
126 }
127
119 switch (rtype) {
120
121 case R_386_NONE: /* none */
122 break;
123
124 case R_386_32: /* S + A */
125 addr = elf_lookup(lf, symidx, 1);
126 if (addr == 0)

--- 24 unchanged lines hidden (view full) ---

151 case R_386_GLOB_DAT: /* S */
152 addr = elf_lookup(lf, symidx, 1);
153 if (addr == 0)
154 return -1;
155 if (*where != addr)
156 *where = addr;
157 break;
158
128 switch (rtype) {
129
130 case R_386_NONE: /* none */
131 break;
132
133 case R_386_32: /* S + A */
134 addr = elf_lookup(lf, symidx, 1);
135 if (addr == 0)

--- 24 unchanged lines hidden (view full) ---

160 case R_386_GLOB_DAT: /* S */
161 addr = elf_lookup(lf, symidx, 1);
162 if (addr == 0)
163 return -1;
164 if (*where != addr)
165 *where = addr;
166 break;
167
159 case R_386_RELATIVE: /* B + A */
160 addr = relocbase + addend;
161 if (*where != addr)
162 *where = addr;
168 case R_386_RELATIVE:
163 break;
164
165 default:
166 printf("kldload: unexpected relocation type %d\n",
167 rtype);
168 return -1;
169 }
170 return(0);
171}
172
173int
169 break;
170
171 default:
172 printf("kldload: unexpected relocation type %d\n",
173 rtype);
174 return -1;
175 }
176 return(0);
177}
178
179int
180elf_reloc(linker_file_t lf, const void *data, int type)
181{
182
183 return (elf_reloc_internal(lf, data, type, 0));
184}
185
186int
187elf_reloc_local(linker_file_t lf, const void *data, int type)
188{
189
190 return (elf_reloc_internal(lf, data, type, 1));
191}
192
193int
174elf_cpu_load_file(linker_file_t lf __unused)
175{
176
177 return (0);
178}
179
180int
181elf_cpu_unload_file(linker_file_t lf __unused)
182{
183
184 return (0);
185}
194elf_cpu_load_file(linker_file_t lf __unused)
195{
196
197 return (0);
198}
199
200int
201elf_cpu_unload_file(linker_file_t lf __unused)
202{
203
204 return (0);
205}