elf_machdep.c (7035cf14ee3b658181facc80b72179e06a9a4f35) elf_machdep.c (36716fe2e6eddac7ab1b9e9b1a268885a3985932)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright 1996-1998 John D. Polstra.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

170 xsave_mask;
171 } else
172 len += elf64_populate_note(NT_X86_XSTATE, NULL, NULL,
173 cpu_max_ext_state_size, NULL);
174 }
175 *off = len;
176}
177
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright 1996-1998 John D. Polstra.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

170 xsave_mask;
171 } else
172 len += elf64_populate_note(NT_X86_XSTATE, NULL, NULL,
173 cpu_max_ext_state_size, NULL);
174 }
175 *off = len;
176}
177
178#define ERI_LOCAL 0x0001
179#define ERI_ONLYIFUNC 0x0002
178bool
179elf_is_ifunc_reloc(Elf_Size r_info)
180{
180
181
182 return (ELF_R_TYPE(r_info) == R_X86_64_IRELATIVE);
183}
184
181/* Process one elf relocation with addend. */
182static int
183elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
185/* Process one elf relocation with addend. */
186static int
187elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
184 int type, elf_lookup_fn lookup, int flags)
188 int type, elf_lookup_fn lookup)
185{
186 Elf64_Addr *where, val;
187 Elf32_Addr *where32, val32;
188 Elf_Addr addr;
189 Elf_Addr addend;
190 Elf_Size rtype, symidx;
191 const Elf_Rel *rel;
192 const Elf_Rela *rela;

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

216 addend = rela->r_addend;
217 rtype = ELF_R_TYPE(rela->r_info);
218 symidx = ELF_R_SYM(rela->r_info);
219 break;
220 default:
221 panic("unknown reloc type %d\n", type);
222 }
223
189{
190 Elf64_Addr *where, val;
191 Elf32_Addr *where32, val32;
192 Elf_Addr addr;
193 Elf_Addr addend;
194 Elf_Size rtype, symidx;
195 const Elf_Rel *rel;
196 const Elf_Rela *rela;

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

220 addend = rela->r_addend;
221 rtype = ELF_R_TYPE(rela->r_info);
222 symidx = ELF_R_SYM(rela->r_info);
223 break;
224 default:
225 panic("unknown reloc type %d\n", type);
226 }
227
224 if (((flags & ERI_ONLYIFUNC) == 0) ^ (rtype != R_X86_64_IRELATIVE))
225 return (0);
226
227 switch (rtype) {
228 case R_X86_64_NONE: /* none */
229 break;
230
231 case R_X86_64_64: /* S + A */
232 error = lookup(lf, symidx, 1, &addr);
233 val = addr + addend;
234 if (error != 0)

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

295 printf("kldload: unexpected relocation type %ld\n",
296 rtype);
297 return (-1);
298 }
299 return (0);
300}
301
302int
228 switch (rtype) {
229 case R_X86_64_NONE: /* none */
230 break;
231
232 case R_X86_64_64: /* S + A */
233 error = lookup(lf, symidx, 1, &addr);
234 val = addr + addend;
235 if (error != 0)

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

296 printf("kldload: unexpected relocation type %ld\n",
297 rtype);
298 return (-1);
299 }
300 return (0);
301}
302
303int
303elf_reloc_ifunc(linker_file_t lf, Elf_Addr relocbase, const void *data,
304 int type, elf_lookup_fn lookup)
305{
306
307 return (elf_reloc_internal(lf, relocbase, data, type, lookup,
308 ERI_ONLYIFUNC));
309}
310
311int
312elf_reloc(linker_file_t lf, Elf_Addr relocbase, const void *data, int type,
313 elf_lookup_fn lookup)
314{
315
304elf_reloc(linker_file_t lf, Elf_Addr relocbase, const void *data, int type,
305 elf_lookup_fn lookup)
306{
307
316 return (elf_reloc_internal(lf, relocbase, data, type, lookup, 0));
308 return (elf_reloc_internal(lf, relocbase, data, type, lookup));
317}
318
319int
320elf_reloc_local(linker_file_t lf, Elf_Addr relocbase, const void *data,
321 int type, elf_lookup_fn lookup)
322{
323
309}
310
311int
312elf_reloc_local(linker_file_t lf, Elf_Addr relocbase, const void *data,
313 int type, elf_lookup_fn lookup)
314{
315
324 return (elf_reloc_internal(lf, relocbase, data, type, lookup,
325 ERI_LOCAL));
316 return (elf_reloc_internal(lf, relocbase, data, type, lookup));
326}
327
328int
329elf_cpu_load_file(linker_file_t lf __unused)
330{
331
332 return (0);
333}
334
335int
336elf_cpu_unload_file(linker_file_t lf __unused)
337{
338
339 return (0);
340}
317}
318
319int
320elf_cpu_load_file(linker_file_t lf __unused)
321{
322
323 return (0);
324}
325
326int
327elf_cpu_unload_file(linker_file_t lf __unused)
328{
329
330 return (0);
331}