Use a magic number to know we were started from the elf wrapper.
Add a dummy _start function to make the non-elf version of the wrapper work.
This commit is contained in:
parent
f5a9ac9ca4
commit
ce4210d673
@ -36,6 +36,14 @@ __FBSDID("$FreeBSD$");
|
||||
extern char kernel_start[];
|
||||
extern char kernel_end[];
|
||||
|
||||
void __start(void);
|
||||
|
||||
void
|
||||
_start(void)
|
||||
{
|
||||
__start();
|
||||
}
|
||||
|
||||
static __inline void *
|
||||
memcpy(void *dst, const void *src, int len)
|
||||
{
|
||||
@ -168,8 +176,10 @@ load_kernel(unsigned int kstart, unsigned int kend, unsigned int curaddr,unsigne
|
||||
phdr[i].p_filesz);
|
||||
}
|
||||
/* Now grab the symbol tables. */
|
||||
*(Elf_Addr *)curaddr = ssym - curaddr + KERNVIRTADDR;
|
||||
*((Elf_Addr *)curaddr + 1) = lastaddr - curaddr + KERNVIRTADDR;
|
||||
*(Elf_Addr *)curaddr = MAGIC_TRAMP_NUMBER;
|
||||
*((Elf_Addr *)curaddr + 1) = ssym - curaddr + KERNVIRTADDR;
|
||||
*((Elf_Addr *)curaddr + 2) = lastaddr - curaddr + KERNVIRTADDR;
|
||||
|
||||
/* Jump to the entry point. */
|
||||
((void(*)(void))(entry_point - KERNVIRTADDR + curaddr))();
|
||||
__asm __volatile(".globl func_end\n"
|
||||
@ -179,7 +189,7 @@ load_kernel(unsigned int kstart, unsigned int kend, unsigned int curaddr,unsigne
|
||||
|
||||
extern char func_end[];
|
||||
|
||||
int _start(void)
|
||||
void __start(void)
|
||||
{
|
||||
void *curaddr;
|
||||
|
||||
@ -194,5 +204,5 @@ int _start(void)
|
||||
((void (*)())dst)((unsigned int)&kernel_start,
|
||||
(unsigned int)&kernel_end, (unsigned int)curaddr,
|
||||
dst + (unsigned int)&func_end -
|
||||
(unsigned int)(&load_kernel),1);
|
||||
(unsigned int)(&load_kernel), 1);
|
||||
}
|
||||
|
@ -125,4 +125,9 @@ __ElfType(Auxinfo);
|
||||
#define ELF_TARG_MACH EM_ARM
|
||||
#define ELF_TARG_VER 1
|
||||
|
||||
/*
|
||||
* Magic number for the elf trampoline, chosen wisely to be an immediate
|
||||
* value.
|
||||
*/
|
||||
#define MAGIC_TRAMP_NUMBER 0x5c000003
|
||||
#endif /* !_MACHINE_ELF_H_ */
|
||||
|
@ -233,16 +233,16 @@ initarm(void *arg, void *arg2)
|
||||
fake_preload[i++] = sizeof(uint32_t);
|
||||
fake_preload[i++] = (uint32_t)&end - KERNBASE - 0x00200000;
|
||||
#ifdef DDB
|
||||
if (*(uint32_t *)KERNVIRTADDR != 0) {
|
||||
if (*(uint32_t *)KERNVIRTADDR == MAGIC_TRAMP_NUMBER) {
|
||||
fake_preload[i++] = MODINFO_METADATA|MODINFOMD_SSYM;
|
||||
fake_preload[i++] = sizeof(vm_offset_t);
|
||||
fake_preload[i++] = *(uint32_t *)KERNVIRTADDR;
|
||||
fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 4);
|
||||
fake_preload[i++] = MODINFO_METADATA|MODINFOMD_ESYM;
|
||||
fake_preload[i++] = sizeof(vm_offset_t);
|
||||
fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 4);
|
||||
lastaddr = *(uint32_t *)(KERNVIRTADDR + 4);
|
||||
fake_preload[i++] = *(uint32_t *)(KERNVIRTADDR + 8);
|
||||
lastaddr = *(uint32_t *)(KERNVIRTADDR + 8);
|
||||
zend = lastaddr;
|
||||
zstart = *(uint32_t *)KERNVIRTADDR;
|
||||
zstart = *(uint32_t *)(KERNVIRTADDR + 4);
|
||||
ksym_start = zstart;
|
||||
ksym_end = zend;
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user