/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/inttypes.h>
#include <sys/elf_notes.h>
#include "dboot_xboot.h"
#include "dboot_elfload.h"
#include "dboot_printf.h"
static void *
getehdr(void)
{
uchar_t *ident;
ident = PGETBYTES(0);
if (ident == NULL)
dboot_panic("Cannot read kernel ELF header");
dboot_panic("not an ELF file!");
if (ident[EI_CLASS] == ELFCLASS32)
else if (ident[EI_CLASS] == ELFCLASS64)
else
dboot_panic("Unknown ELF class");
return (hdr);
}
/*
* parse the elf file for program information
*/
int
{
int i;
dboot_panic("getehdr() failed");
dboot_panic("no program headers");
/*
* Get the program headers.
*/
dboot_panic("Failed to get program headers e_phnum = %d",
/*
* Get the section headers.
*/
dboot_panic("Failed to get section headers e_shnum = %d",
/*
* Next look for interesting program headers.
*/
/*LINTED [ELF program header alignment]*/
/*
* Dynamically-linked executable.
* Complain.
*/
dboot_printf("warning: PT_INTERP section\n");
continue;
}
/*
* at this point we only care about PT_LOAD segments
*/
continue;
dboot_printf("warning: krtld reloc info?\n");
continue;
}
/*
* If memory size is zero just ignore this header.
*/
continue;
/*
* If load address 1:1 then ignore this header.
*/
if (prom_debug)
dboot_printf("Skipping PT_LOAD segment for "
continue;
}
/*
* copy the data to kernel area
*/
dboot_panic("Bad paddr for kernel nucleus segment");
if (prom_debug)
dboot_printf("copying %ld bytes from ELF offset 0x%lx "
"to physaddr 0x%lx (va=0x%lx)\n",
}
/*
* Next look for bss
*/
/* zero out bss */
if (prom_debug)
dboot_printf("zeroing BSS %ld bytes from "
"physaddr 0x%llx (end=0x%llx)\n",
(long long unsigned)next_addr,
break;
}
}
/*
* Ignore the intepreter (or should we die if there is one??)
*/
return (0);
}