mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-22 15:47:37 +00:00
Try to be a little smart at guessing where _start is located in flash, instead
of relying on a binutils bug. Reported by: dim
This commit is contained in:
parent
e4c690b4f0
commit
306cc0acfb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214648
@ -159,7 +159,7 @@ _startC(void)
|
||||
#if defined(FLASHADDR) && defined(LOADERRAMADDR)
|
||||
unsigned int pc;
|
||||
|
||||
__asm __volatile("adr %0, _start\n"
|
||||
__asm __volatile("mov %0, pc\n"
|
||||
: "=r" (pc));
|
||||
if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) ||
|
||||
(FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) {
|
||||
@ -173,11 +173,13 @@ _startC(void)
|
||||
*/
|
||||
unsigned int target_addr;
|
||||
unsigned int tmp_sp;
|
||||
uint32_t src_addr = (uint32_t)&_start - PHYSADDR + FLASHADDR
|
||||
+ (pc - FLASHADDR - ((uint32_t)&_startC - PHYSADDR)) & 0xfffff000;
|
||||
|
||||
target_addr = (unsigned int)&_start - PHYSADDR + LOADERRAMADDR;
|
||||
tmp_sp = target_addr + 0x100000 +
|
||||
(unsigned int)&_end - (unsigned int)&_start;
|
||||
memcpy((char *)target_addr, (char *)pc,
|
||||
memcpy((char *)target_addr, (char *)src_addr,
|
||||
(unsigned int)&_end - (unsigned int)&_start);
|
||||
/* Temporary set the sp and jump to the new location. */
|
||||
__asm __volatile(
|
||||
|
Loading…
Reference in New Issue
Block a user