llext: add object test case
Adds a case to the simple llext test testing global non-static object relocation. Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
This commit is contained in:
parent
33c6bdab9a
commit
ce24394437
|
@ -16,7 +16,7 @@ target_include_directories(app PRIVATE
|
|||
)
|
||||
|
||||
# generate extension targets foreach extension given by name
|
||||
foreach(ext_name hello_world logging relative_jump)
|
||||
foreach(ext_name hello_world logging relative_jump object)
|
||||
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)
|
||||
|
|
26
tests/subsys/llext/simple/src/object_ext.c
Normal file
26
tests/subsys/llext/simple/src/object_ext.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code demonstrates object relocation support.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <zephyr/llext/symbol.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
/* Test non-static global object relocation */
|
||||
int number = 42;
|
||||
const char *string = "hello";
|
||||
|
||||
void test_entry(void)
|
||||
{
|
||||
printk("number: %d\n", number);
|
||||
number = 0;
|
||||
printk("number, updated: %d\n", number);
|
||||
printk("string: %s\n", string);
|
||||
}
|
||||
LL_EXTENSION_SYMBOL(test_entry);
|
|
@ -152,6 +152,11 @@ static LLEXT_CONST uint8_t relative_jump_ext[] __aligned(4) = {
|
|||
};
|
||||
LLEXT_LOAD_UNLOAD(relative_jump, true)
|
||||
|
||||
static LLEXT_CONST uint8_t object_ext[] __aligned(4) = {
|
||||
#include "object.inc"
|
||||
};
|
||||
LLEXT_LOAD_UNLOAD(object, true)
|
||||
|
||||
/*
|
||||
* Ensure that EXPORT_SYMBOL does indeed provide a symbol and a valid address
|
||||
* to it.
|
||||
|
|
Loading…
Reference in a new issue