Skip to content

Commit

Permalink
llext: add movt/movw relocation test
Browse files Browse the repository at this point in the history
Arch arm relocatate test covers:
R_ARM_ABS32: all tests
decode_thm_jumps -> relative jmp extension
decode_thm_movs -> movwmovt extension

Signed-off-by: Cedric Lescop <cedric.lescop@se.com>
  • Loading branch information
selescop committed Mar 22, 2024
1 parent a5ac769 commit fc85b55
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/subsys/llext/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_include_directories(app PRIVATE

if(NOT LOADER_BUILD_ONLY)
# generate extension targets foreach extension given by name
foreach(ext_name hello_world logging relative_jump object)
foreach(ext_name hello_world logging relative_jump object movwmovt)
set(ext_src ${PROJECT_SOURCE_DIR}/src/${ext_name}_ext.c)
set(ext_bin ${ZEPHYR_BINARY_DIR}/${ext_name}.llext)
set(ext_inc ${ZEPHYR_BINARY_DIR}/include/generated/${ext_name}.inc)
Expand Down
32 changes: 32 additions & 0 deletions tests/subsys/llext/simple/src/movwmovt_ext.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Schneider Electric.
*
* SPDX-License-Identifier: Apache-2.0
*/

/*
* This test is designed to test MOV.W and MOV.T instructions on ARM architectures.
* (except M0 & M0+, not supported)
*/

#include <stdint.h>
#include <zephyr/llext/symbol.h>
#include <zephyr/sys/printk.h>


static void test_func(void)
{
printk("%s\n", __func__);
}

void test_entry(void)
{
test_func();
#if defined(CONFIG_ARM) && !defined(CONFIG_CPU_CORTEX_M0) && !defined(CONFIG_CPU_CORTEX_M0PLUS)
printk("test movwmovt\n");
__asm volatile ("movw r0, #:lower16:test_func");
__asm volatile ("movt r0, #:upper16:test_func");
__asm volatile ("blx r0");
#endif
}
LL_EXTENSION_SYMBOL(test_entry);
7 changes: 7 additions & 0 deletions tests/subsys/llext/simple/src/test_llext_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ static LLEXT_CONST uint8_t object_ext[] __aligned(4) = {
LLEXT_LOAD_UNLOAD(object, true)
#endif /* ! LOADER_BUILD_ONLY */

#if defined(CONFIG_ARM) && !defined(CONFIG_CPU_CORTEX_M0) && !defined(CONFIG_CPU_CORTEX_M0PLUS)
static LLEXT_CONST uint8_t movwmovt_ext[] __aligned(4) = {
#include "movwmovt.inc"
};
LLEXT_LOAD_UNLOAD(movwmovt, true)
#endif

/*
* Ensure that EXPORT_SYMBOL does indeed provide a symbol and a valid address
* to it.
Expand Down

0 comments on commit fc85b55

Please sign in to comment.