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 Apr 2, 2024
1 parent 557efb6 commit 7a8da39
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
32 changes: 21 additions & 11 deletions tests/subsys/llext/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ 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 syscalls)
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)
add_llext_target(${ext_name}_ext
OUTPUT ${ext_bin}
SOURCES ${ext_src}
)
generate_inc_file_for_target(app ${ext_bin} ${ext_inc})
endforeach()

set(ext_basename ext_name hello_world logging relative_jump object syscalls)

if(CONFIG_ARM)
if(NOT CONFIG_CPU_CORTEX_M0 AND NOT CONFIG_CPU_CORTEX_M0PLUS AND NOT CONFIG_CPU_CORTEX_M1)
list(APPEND ext_basename movwmovt)
endif()
endif()

# generate extension targets foreach extension given by basename
foreach(${ext_basename})
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)
add_llext_target(${ext_name}_ext
OUTPUT ${ext_bin}
SOURCES ${ext_src}
)
generate_inc_file_for_target(app ${ext_bin} ${ext_inc})
endforeach()

endif()
31 changes: 31 additions & 0 deletions tests/subsys/llext/simple/src/movwmovt_ext.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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();

printk("test movwmovt\n");
__asm volatile ("movw r0, #:lower16:test_func");
__asm volatile ("movt r0, #:upper16:test_func");
__asm volatile ("blx r0");
}
LL_EXTENSION_SYMBOL(test_entry);

0 comments on commit 7a8da39

Please sign in to comment.