Skip to content

Commit 4606d27

Browse files
OSU: PIC - Disable relocation of addresses in RAM
In the context of an OSU, the `pic` function used to link addresses in RAM. Those addresses are already known at compile time. Applying this relocation triggered incorrect behaviors.
1 parent 16f3cb7 commit 4606d27

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/pic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "os_pic.h"
33

44
#if !defined(HAVE_BOLOS) || defined(BOLOS_OS_UPGRADER_APP)
5-
#pragma GCC diagnostic push
6-
#pragma GCC diagnostic ignored "-Wunused-parameter"
5+
#pragma GCC diagnostic push
6+
#pragma GCC diagnostic ignored "-Wunused-parameter"
77
__attribute__((naked, no_instrument_function)) static void *pic_internal(void *link_address)
88
{
99
// compute the delta offset between LinkMemAddr & ExecMemAddr
@@ -53,6 +53,7 @@ void *pic(void *link_address)
5353
link_address = pic_internal(link_address);
5454
}
5555

56+
#ifndef BOLOS_OS_UPGRADER_APP
5657
// check if in the LINKED RAM zone
5758
__asm volatile("ldr %0, =_bss" : "=r"(n));
5859
__asm volatile("ldr %0, =_estack" : "=r"(en));
@@ -61,6 +62,7 @@ void *pic(void *link_address)
6162
// deref into the RAM therefore add the RAM offset from R9
6263
link_address = (char *) link_address - (char *) n + (char *) en;
6364
}
65+
#endif // BOLOS_OS_UPGRADER_APP
6466

6567
return link_address;
6668
}

0 commit comments

Comments
 (0)