8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2011 Bayard G. Bell <buffer.g.overflow@gmail.com>.
27 * All rights reserved. Use is subject to license terms.
28 * Copyright (c) 2018, Joyent, Inc.
29 */
30
31 /*
32 * Kernel's linker/loader
33 */
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/sysmacros.h>
38 #include <sys/systm.h>
39 #include <sys/user.h>
40 #include <sys/kmem.h>
41 #include <sys/reboot.h>
42 #include <sys/bootconf.h>
43 #include <sys/debug.h>
44 #include <sys/uio.h>
45 #include <sys/file.h>
46 #include <sys/vnode.h>
47 #include <sys/user.h>
48 #include <sys/mman.h>
406 /*
407 * OBP allows us to read both the ramdisk and
408 * the underlying root fs when root is a disk.
409 * This can lower incidences of unbootable systems
410 * when the archive is out-of-date with the /etc
411 * state files.
412 */
413 if (BOP_MOUNTROOT() != BOOT_SVC_OK) {
414 _kobj_printf(ops, "can't mount boot fs\n");
415 goto fail;
416 }
417 #else
418 {
419 /* on x86, we always boot with a ramdisk */
420 (void) kobj_boot_mountroot();
421
422 /*
423 * Now that the ramdisk is mounted, finish boot property
424 * initialization.
425 */
426 boot_prop_finish();
427 }
428
429 #if !defined(_UNIX_KRTLD)
430 /*
431 * 'unix' is linked together with 'krtld' into one executable and
432 * the early boot code does -not- hand us any of the dynamic metadata
433 * about the executable. In particular, it does not read in, map or
434 * otherwise look at the program headers. We fake all that up now.
435 *
436 * We do this early as DTrace static probes and tnf probes both call
437 * undefined references. We have to process those relocations before
438 * calling any of them.
439 *
440 * OBP tells kobj_start() where the ELF image is in memory, so it
441 * synthesized bootaux before kobj_init() was called
442 */
443 if (bootaux[BA_PHDR].ba_ptr == NULL)
444 synthetic_bootaux(filename, bootaux);
445
446 #endif /* !_UNIX_KRTLD */
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2011 Bayard G. Bell <buffer.g.overflow@gmail.com>.
27 * All rights reserved. Use is subject to license terms.
28 * Copyright 2020 Joyent, Inc.
29 */
30
31 /*
32 * Kernel's linker/loader
33 */
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/sysmacros.h>
38 #include <sys/systm.h>
39 #include <sys/user.h>
40 #include <sys/kmem.h>
41 #include <sys/reboot.h>
42 #include <sys/bootconf.h>
43 #include <sys/debug.h>
44 #include <sys/uio.h>
45 #include <sys/file.h>
46 #include <sys/vnode.h>
47 #include <sys/user.h>
48 #include <sys/mman.h>
406 /*
407 * OBP allows us to read both the ramdisk and
408 * the underlying root fs when root is a disk.
409 * This can lower incidences of unbootable systems
410 * when the archive is out-of-date with the /etc
411 * state files.
412 */
413 if (BOP_MOUNTROOT() != BOOT_SVC_OK) {
414 _kobj_printf(ops, "can't mount boot fs\n");
415 goto fail;
416 }
417 #else
418 {
419 /* on x86, we always boot with a ramdisk */
420 (void) kobj_boot_mountroot();
421
422 /*
423 * Now that the ramdisk is mounted, finish boot property
424 * initialization.
425 */
426 read_bootenvrc();
427 }
428
429 #if !defined(_UNIX_KRTLD)
430 /*
431 * 'unix' is linked together with 'krtld' into one executable and
432 * the early boot code does -not- hand us any of the dynamic metadata
433 * about the executable. In particular, it does not read in, map or
434 * otherwise look at the program headers. We fake all that up now.
435 *
436 * We do this early as DTrace static probes and tnf probes both call
437 * undefined references. We have to process those relocations before
438 * calling any of them.
439 *
440 * OBP tells kobj_start() where the ELF image is in memory, so it
441 * synthesized bootaux before kobj_init() was called
442 */
443 if (bootaux[BA_PHDR].ba_ptr == NULL)
444 synthetic_bootaux(filename, bootaux);
445
446 #endif /* !_UNIX_KRTLD */
|