MCPcopy Create free account
hub / github.com/F-Stack/f-stack / preload_bootstrap_relocate

Function preload_bootstrap_relocate

freebsd/kern/subr_module.c:280–313  ·  view source on GitHub ↗

Called from locore. Convert physical pointers to kvm. Sigh. */

Source from the content-addressed store, hash-verified

278
279/* Called from locore. Convert physical pointers to kvm. Sigh. */
280void
281preload_bootstrap_relocate(vm_offset_t offset)
282{
283 caddr_t curp;
284 uint32_t *hdr;
285 vm_offset_t *ptr;
286 int next;
287
288 if (preload_metadata != NULL) {
289 curp = preload_metadata;
290 for (;;) {
291 hdr = (uint32_t *)curp;
292 if (hdr[0] == 0 && hdr[1] == 0)
293 break;
294
295 /* Deal with the ones that we know we have to fix */
296 switch (hdr[0]) {
297 case MODINFO_ADDR:
298 case MODINFO_METADATA|MODINFOMD_FONT:
299 case MODINFO_METADATA|MODINFOMD_SSYM:
300 case MODINFO_METADATA|MODINFOMD_ESYM:
301 ptr = (vm_offset_t *)(curp + (sizeof(uint32_t) * 2));
302 *ptr += offset;
303 break;
304 }
305 /* The rest is beyond us for now */
306
307 /* skip to next field */
308 next = sizeof(uint32_t) * 2 + hdr[1];
309 next = roundup(next, sizeof(u_long));
310 curp += next;
311 }
312 }
313}
314
315/*
316 * Parse the modinfo type and append to the provided sbuf.

Callers 4

init386Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected