|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v2 5/5] lib/syscall_shim: Option to generate libc-style stubs
Reviewed-by: Gaulthier Gain <gaulthier.gain@xxxxxxxxx>
> On 3 Apr 2020, at 18:29, Simon Kuenzer <simon.kuenzer@xxxxxxxxx> wrote:
>
> Introduces the option to automatically generate libc-style system call
> stubs for unavailable system calls. With this function, it is possible
> to provide all libc-style system call symbols although just a subset
> of the full API is implemented. The symbols are defined as `weak` and
> can be replaced by non-weak symbol definitions.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
> lib/syscall_shim/Config.uk | 15 +++++++++++++++
> lib/syscall_shim/Makefile.uk | 8 ++++++++
> lib/syscall_shim/gen_libc_stubs.awk | 16 ++++++++++++++++
> 3 files changed, 39 insertions(+)
> create mode 100644 lib/syscall_shim/gen_libc_stubs.awk
>
> diff --git a/lib/syscall_shim/Config.uk b/lib/syscall_shim/Config.uk
> index c3369463..9c39ed2f 100644
> --- a/lib/syscall_shim/Config.uk
> +++ b/lib/syscall_shim/Config.uk
> @@ -9,6 +9,21 @@ if LIBSYSCALL_SHIM
> bool
> default n
>
> + config LIBSYSCALL_SHIM_LIBCSTUBS
> + depends on !LIBSYSCALL_SHIM_NOWRAPPER
> + bool "Provide libc-style stubs"
> + default n
> + help
> + Automatically generate libc-style stubs for unavailable
> + system calls. The aim is to provide all libc-style system
> + call symbols although just a subset of the full API may be
> + implemtented. The symbols are defined as `weak`.
> + Please note that depending on the used compiler and optimization
> + options, this functionality may sometimes cause linking failures
> + because of double definitions of symbols. This is the case when
> + another library is providing some libc-style system calls
> + without registering them to libsyscall_shim.
> +
> config LIBSYSCALL_SHIM_HANDLER
> bool "Binary system call handler (Linux ABI)"
> default n
> diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk
> index c01ee494..d3bfe4f8 100644
> --- a/lib/syscall_shim/Makefile.uk
> +++ b/lib/syscall_shim/Makefile.uk
> @@ -12,6 +12,7 @@ LIBSYSCALL_SHIM_GEN_SRC +=
> $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c
> LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c
> +LIBSYSCALL_SHIM_GEN_SRC += $(LIBSYSCALL_SHIM_BUILD)/libc_stubs.c
>
> UK_PREPARE-$(CONFIG_LIBSYSCALL_SHIM) += $(LIBSYSCALL_SHIM_PHONY_SRC)
> $(LIBSYSCALL_SHIM_GEN_SRC)
>
> @@ -65,6 +66,11 @@ $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c:
> $(LIBSYSCALL_SHIM_BUILD)/provided_
> $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
> $(AWK) -F '-' -f
> $(LIBSYSCALL_SHIM_BASE)/gen_uk_syscall_name_p.awk $< > $@)
>
> +$(LIBSYSCALL_SHIM_BUILD)/libc_stubs.c:
> $(LIBSYSCALL_SHIM_BASE)/gen_libc_stubs.awk $(LIBSYSCALL_SHIM_TEMPL)
> + $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
> + $(AWK) -f $(LIBSYSCALL_SHIM_BASE)/gen_libc_stubs.awk \
> + $(LIBSYSCALL_SHIM_TEMPL) > $@)
> +
> $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in.new:
> $(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
> echo $(UK_PROVIDED_SYSCALLS-y) | tr ' ' '\n' > $@)
> @@ -85,5 +91,7 @@ LIBSYSCALL_SHIM_SRCS-y +=
> $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_r.c
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name.c
> LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall_name_p.c
> +LIBSYSCALL_SHIM_SRCS-$(CONFIG_LIBSYSCALL_SHIM_LIBCSTUBS) +=
> $(LIBSYSCALL_SHIM_BUILD)/libc_stubs.c
> +LIBSYSCALL_SHIM_LIBC_STUBS_FLAGS+=-fno-builtin
> -Wno-builtin-declaration-mismatch
>
> LIBSYSCALL_SHIM_CLEAN = $(LIBSYSCALL_SHIM_PHONY_SRC)
> $(LIBSYSCALL_SHIM_PHONY_SRC_NEW) $(LIBSYSCALL_SHIM_GEN_SRC)
> $(LIBSYSCALL_SHIM_GEN_SRC)
> diff --git a/lib/syscall_shim/gen_libc_stubs.awk
> b/lib/syscall_shim/gen_libc_stubs.awk
> new file mode 100644
> index 00000000..265c8fa9
> --- /dev/null
> +++ b/lib/syscall_shim/gen_libc_stubs.awk
> @@ -0,0 +1,16 @@
> +BEGIN {
> + print "/* Auto generated file. Do not edit */"
> + print "\n#include <errno.h>"
> + print "\n#include <uk/syscall.h>"
> + print "\n#include <uk/print.h>"
> + print "\n#include <uk/essentials.h>"
> +}
> +/#define __NR_/ {
> + name = substr($2,6);
> + printf "\n#ifndef HAVE_uk_syscall_%s", name;
> + printf "\nlong __weak %s(void)", name;
> + printf "\n{";
> + printf "\n\treturn uk_syscall_e_stub(\"%s\");", name;
> + printf "\n}";
> + printf "\n#endif /* !HAVE_uk_syscall_%s */\n", name;
> +}
> --
> 2.20.1
>
>
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/minios-devel
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |