diff options
author | cognet <cognet@FreeBSD.org> | 2005-11-24 02:27:55 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2005-11-24 02:27:55 +0000 |
commit | 792c8e2f4900802933c70899fadd6312270e880d (patch) | |
tree | b91167727d6cc4241e3294a69ded61fbe3e076fd /sys | |
parent | 2a2203ec202a935c64457164772bd84ca2d2814c (diff) | |
download | FreeBSD-src-792c8e2f4900802933c70899fadd6312270e880d.zip FreeBSD-src-792c8e2f4900802933c70899fadd6312270e880d.tar.gz |
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.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arm/arm/elf_trampoline.c | 18 | ||||
-rw-r--r-- | sys/arm/include/elf.h | 5 | ||||
-rw-r--r-- | sys/arm/xscale/i80321/iq31244_machdep.c | 10 |
3 files changed, 24 insertions, 9 deletions
diff --git a/sys/arm/arm/elf_trampoline.c b/sys/arm/arm/elf_trampoline.c index cfe17ba..aad5d85 100644 --- a/sys/arm/arm/elf_trampoline.c +++ b/sys/arm/arm/elf_trampoline.c @@ -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); } diff --git a/sys/arm/include/elf.h b/sys/arm/include/elf.h index a6f1462..81351e8 100644 --- a/sys/arm/include/elf.h +++ b/sys/arm/include/elf.h @@ -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_ */ diff --git a/sys/arm/xscale/i80321/iq31244_machdep.c b/sys/arm/xscale/i80321/iq31244_machdep.c index a49a3f7..990b5b6 100644 --- a/sys/arm/xscale/i80321/iq31244_machdep.c +++ b/sys/arm/xscale/i80321/iq31244_machdep.c @@ -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 |