llext: add movt/movw relocation test
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>
This commit is contained in:
parent
7b1d9d6166
commit
b573f447f0
2 changed files with 59 additions and 20 deletions
|
@ -16,25 +16,33 @@ target_include_directories(app PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT LOADER_BUILD_ONLY)
|
if(NOT LOADER_BUILD_ONLY)
|
||||||
# generate extension targets foreach extension given by name
|
set(ext_names hello_world logging relative_jump object syscalls threads_kernel_objects)
|
||||||
foreach(ext_name hello_world logging relative_jump object syscalls threads_kernel_objects)
|
|
||||||
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()
|
|
||||||
|
|
||||||
# Add a dummy custom processing command to test add_llext_command
|
if(CONFIG_ARM)
|
||||||
get_target_property(proc_in_file hello_world_ext lib_output)
|
if(NOT CONFIG_CPU_CORTEX_M0 AND NOT CONFIG_CPU_CORTEX_M0PLUS AND NOT CONFIG_CPU_CORTEX_M1)
|
||||||
get_target_property(proc_out_file hello_world_ext pkg_input)
|
list(APPEND ext_names movwmovt)
|
||||||
add_llext_command(
|
endif()
|
||||||
TARGET hello_world_ext
|
endif()
|
||||||
POST_BUILD
|
|
||||||
COMMAND echo "dummy patching ${proc_in_file} to create ${proc_out_file}"
|
# generate extension targets foreach extension given by 'ext_names'
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${proc_in_file} ${proc_out_file}
|
foreach(ext_name ${ext_names})
|
||||||
)
|
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()
|
||||||
|
|
||||||
|
# Add a dummy custom processing command to test add_llext_command
|
||||||
|
get_target_property(proc_in_file hello_world_ext lib_output)
|
||||||
|
get_target_property(proc_out_file hello_world_ext pkg_input)
|
||||||
|
add_llext_command(
|
||||||
|
TARGET hello_world_ext
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND echo "dummy patching ${proc_in_file} to create ${proc_out_file}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${proc_in_file} ${proc_out_file}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
31
tests/subsys/llext/simple/src/movwmovt_ext.c
Normal file
31
tests/subsys/llext/simple/src/movwmovt_ext.c
Normal file
|
@ -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 Cortex-M0, M0+ and M1, that don't support them)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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);
|
Loading…
Add table
Add a link
Reference in a new issue