From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [RFC PATCH] Mini-OS: explicitly mark symbols to be visible for apps
Date: Sat, 25 Nov 2023 23:24:11 +0100 [thread overview]
Message-ID: <20231125222411.o7rf6awppslwhsro@begin> (raw)
In-Reply-To: <20231124135903.16621-1-jgross@suse.com>
Juergen Gross, le ven. 24 nov. 2023 14:59:03 +0100, a ecrit:
> Add an EXPORT_SYMBOL() macro to explicitly mark a symbol to be visible
> for an app or library linked with Mini-OS. This enables to hide all
> other symbols from external components, avoiding any problems with
> duplicate symbol names.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> Based on top of my previous series "Mini-OS: hide mini-os internal
> symbols".
> This is a RFC as an alternative to the map file containing all
> visible symbol names. It would add more code churn, but it has the
> large benefit of declaring visibility of a symbol at the place
> where it is defined, reducing the chance to miss a proper symbol
> visibility definition.
> This patch is including an example for the do_exit() function in
> order to prove the viability of the approach.
> In case this idea is approved, I'd setup a patch series replacing
> the second patch of above series with this patch (minus the do_exit()
> example) and the scattered EXPORT_SYMBOL() instances.
I agree on the rationale, indeed.
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> Makefile | 3 ++-
> include/lib.h | 6 ++++++
> kernel.c | 1 +
> mini-os.map | 1 -
> 4 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d4768110..5dbad8ce 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -166,7 +166,8 @@ $(OBJ_DIR)/arch/x86/minios-x86%.lds: arch/x86/minios-x86.lds.S
>
> $(OBJ_DIR)/$(TARGET)-kern.o: $(OBJS) arch_lib $(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds mini-os.map
> $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o $@
> - $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* --keep-global-symbols=mini-os.map $@ $@
> + $(OBJCOPY) --dump-section .export_symbol=syms mini-os-kern.o
> + $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* --keep-global-symbols=mini-os.map --keep-global-symbols=syms --remove-section=.export_symbol $@ $@
>
> $(OBJ_DIR)/$(TARGET): $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O)
> $(LD) -r $(LDFLAGS) $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O) $(LDLIBS) -o $@.o
> diff --git a/include/lib.h b/include/lib.h
> index dd68985a..24fd0186 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -64,6 +64,12 @@
> #define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
> #endif
>
> +#define EXPORT_SYMBOL(sym) \
> + extern typeof(sym) sym; \
> + asm(".section \".export_symbol\",\"a\"\n" \
> + "\t.ascii \""#sym"\n\"\n" \
> + ".previous")
> +
> #ifdef HAVE_LIBC
> #include <sys/queue.h>
> #include <sys/stat.h>
> diff --git a/kernel.c b/kernel.c
> index 1f97d8dd..29eed535 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -199,3 +199,4 @@ void do_exit(void)
> HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
> }
> }
> +EXPORT_SYMBOL(do_exit);
> diff --git a/mini-os.map b/mini-os.map
> index 58a3a0ee..90f02edf 100644
> --- a/mini-os.map
> +++ b/mini-os.map
> @@ -69,7 +69,6 @@ close
> closedir
> closelog
> connect
> -do_exit
> dup
> dup2
> err
> --
> 2.35.3
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.
prev parent reply other threads:[~2023-11-25 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 13:59 [RFC PATCH] Mini-OS: explicitly mark symbols to be visible for apps Juergen Gross
2023-11-25 22:24 ` Samuel Thibault [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231125222411.o7rf6awppslwhsro@begin \
--to=samuel.thibault@ens-lyon.org \
--cc=jgross@suse.com \
--cc=minios-devel@lists.xenproject.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.