2023-09-06 21:52:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <zephyr/llext/symbol.h>
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(strcpy);
|
|
|
|
EXPORT_SYMBOL(strncpy);
|
|
|
|
EXPORT_SYMBOL(strlen);
|
|
|
|
EXPORT_SYMBOL(strcmp);
|
|
|
|
EXPORT_SYMBOL(strncmp);
|
|
|
|
EXPORT_SYMBOL(memcmp);
|
|
|
|
EXPORT_SYMBOL(memcpy);
|
|
|
|
EXPORT_SYMBOL(memset);
|
syscalls: llext: Export z_impl symbols so they are available to kernel
commit 67bb6db3f8e5 ("syscall: Export all emitted syscalls, enabling
them for extensions") exports all emitted syscalls, however, it does
that only for the `z_mrsh` symbols, effectively only available for
userspace. If an extension running at kernel level tries to use a
syscall, it will fail to load.
This patch fixes that by exposing the `z_impl` symbols instead. However,
this is not as straightforward as the `z_mrsh` ones. As, in their
signatures, they can basically contain any type, it's not just a matter
of emitting `EXPORT_SYMBOL(z_impl_<syscall>)`, as the compiler will
complain about the undefined types. Here, there are a few approaches.
One of them is to have the `EXPORT_SYMBOL` being generated on the same
files where the syscall is implemented - injecting it there would allow
it to access all known symbols. But changing a lot of files is
undesirable, and it was one of the nice points of first patch.
Another one would be to reconstruct - or simply use the absolute path -
for the includes where the syscalls are defined. Reconstruct the paths
seems fragile and I'm not sure using absolute paths is portable.
Finally, the approach used in this patch is to declare, on a different
generated file, all `z_impl_` symbols as `void *` - after all, only the
address (and the name) to the function is relevant to EXPORT_SYMBOL. By
living in an compilation unit that doesn't include any header which
would expose any of the syscalls, there shouldn't be any conflicts. And
to account for the possibility that a syscall is not compiled - due
being configured out via Kconfig - all those symbols are also weak
aliases to a pointer to NULL. This file is then included in
`llext_export.c` (which should naturally not include any conflicting
header).
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-03-22 06:51:15 +08:00
|
|
|
|
2024-05-24 22:09:31 +08:00
|
|
|
#include <zephyr/syscall_export_llext.c>
|