On Sun, Nov 21, 2021 at 11:09 AM Waldemar Kozaczuk <[email protected]>
wrote:

> This patch is the first one in the series that annotates relevant
> symbols across number of source files in order to expose or hide them
> when kernel is compiled to hide non-glibc symbols. Please note that none
> of this patches neither hides nor exposes any symbols. In essense it will
> only have an effect once we make changes to the makefile to allow compiling
> the kernel with most symbols hidden.
>
> This patch adds new header - export.h - with new macros that either
> expose (__visibility__("default")) or hide (__visibility__("hidden"))
> the symbols. Please read the comments in the header file for more
> details.
>
> Signed-off-by: Waldemar Kozaczuk <[email protected]>
> ---
>  include/osv/export.h | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 include/osv/export.h
>
> diff --git a/include/osv/export.h b/include/osv/export.h
> new file mode 100644
> index 00000000..e6266fcc
> --- /dev/null
> +++ b/include/osv/export.h
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2021 Waldemar Kozaczuk
> + *
> + * This work is open source software, licensed under the terms of the
> + * BSD license as described in the LICENSE file in the top-level
> directory.
> + */
> +
> +#ifndef EXPORT_H
> +#define EXPORT_H
> +
> +//
> +// Please note that the macros below are used in the source files and
> +// are intended to expose the annotated symbols as public when the kernel
> +// files are compiled with the flag '-fvisibility=hidden'. When the kernel
> +// is compiled without compatibility flag, these macro do not have any
> affect
>

You refer to "compatibility flag" a few times in this comment, and I didn't
understand
what it means. Compatibility with what?


> +// as all symbols in this case are exposed as public. So either way, the
> symbols
> +// annotated with these macros yield desired effect.
> +// We do not really need to define a macro for each Linux glibc library
> and we could
> +// have had single OSV_GLIBC_API macro instead of eight ones below.
> However by
> +// having a macro for each library shared file where a symbol is part of,
> +// we automatically self-document the code and in future could
> auto-generate some
> +// docs.
> +#define OSV_LIBAIO_API __attribute__((__visibility__("default")))
> +#define OSV_LIBC_API __attribute__((__visibility__("default")))
> +#define OSV_LIBM_API __attribute__((__visibility__("default")))
> +#define OSV_LIBBSD_API __attribute__((__visibility__("default")))
> +#define OSV_LIBPTHREAD_API __attribute__((__visibility__("default")))
> +#define OSV_LIBUTIL_API __attribute__((__visibility__("default")))
> +#define OSV_LIBXENSTORE_API __attribute__((__visibility__("default")))
> +#define OSV_LD_LINUX_x86_64_API __attribute__((__visibility__("default")))
> +
> +// In some very few cases, when source files are compiled without
> compatibility
> +// flag in order to expose most symbols in the corresponding file, there
> are some specific
> +// symbols in the same file that we want to hide and this is where we use
> this macro.
> +// Regardless if we hide most symbols in the kernel or not, the annotated
> symbols would
> +// be always hidden.
> +#define OSV_HIDDEN __attribute__((__visibility__("hidden")))
>

In commit 815398537f665fca72b4c2040a6f70262d597ac5 you added, following
musl,
the macro "hidden", in lowercase. Maybe we should use that instead of the
uglier OSV_HIDDEN?
Or maybe "hidden" is too short/lowercase? But then again, we already have
it...

+
> +#endif /* EXPORT_H */
> --
> 2.31.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20211121090925.22630-1-jwkozaczuk%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjuOf82xjTx_g3pAj86Jo2WwVxU3QCLV8M_DQYTfHmf66A%40mail.gmail.com.

Reply via email to