diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-01-11 11:45:47 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-01-11 16:18:11 +0100 |
commit | 963a26c34b89d1d2d2ea6ffde251b771b68ac5ef (patch) | |
tree | 44c2df3b68b7ca36cb8aefb7aecf4b15eedbc37c /testsuites/libtests/ofw01/init.c | |
parent | build: Fix build item format (diff) | |
download | rtems-963a26c34b89d1d2d2ea6ffde251b771b68ac5ef.tar.bz2 |
libtests/ofw01: Fix wrapped in bsp_fdt_get()
Use the stack pointer to check if we have to return the real device tree
since bsp_fdt_get() may get called before the BSS is cleared to zero.
Diffstat (limited to '')
-rw-r--r-- | testsuites/libtests/ofw01/init.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/testsuites/libtests/ofw01/init.c b/testsuites/libtests/ofw01/init.c index 6006121cc7..6afed33475 100644 --- a/testsuites/libtests/ofw01/init.c +++ b/testsuites/libtests/ofw01/init.c @@ -37,6 +37,7 @@ #include <bsp/fdt.h> #include <ofw/ofw.h> #include <ofw/ofw_test.h> +#include <rtems/score/isr.h> #include "some.h" @@ -50,7 +51,20 @@ const void *__real_bsp_fdt_get(void); const void *__wrap_bsp_fdt_get(void) { - if (test_bin != NULL) { + uintptr_t sp; + + sp = (uintptr_t) __builtin_frame_address(0); + RTEMS_OBFUSCATE_VARIABLE(sp); + + /* + * Use the stack pointer to check if we have to return the real device tree + * since bsp_fdt_get() may get called before the BSS is cleared to zero. + */ + if ( + (sp < (uintptr_t) _ISR_Stack_area_begin || + sp >= (uintptr_t) _ISR_Stack_area_end) && + test_bin != NULL + ) { return test_bin; } |