On Thu, Oct 27, 2016 at 3:06 PM, Benoît Canet <
[email protected]> wrote:

> Go use this on linux to lookup time. We need a shared
> libary that we will expose to the go runtime by passing
> it's pointer via auxv in order for go to resolve this
> kinds of symbols.
>
> We cannot pass the kernel library as vdso because it's
> located at address 0 and Go runtime will guard against
> this.
>

I still don't understand that last comment - what is located at address 0?
I believe that in the same way we represent any shared object, we also have
a representation (program::_core points to it), so I don't yet understand
why it's not possible to do it that way. Maybe there are other problems
preventing this from working, but I didn't understand the "address 0" issue.


>
> Signed-off-by: Benoît Canet <[email protected]>
> ---
>  Makefile                |  7 ++++++-
>  bootfs.manifest.skel    |  1 +
>  libc/vdso/vdso.c        | 18 ++++++++++++++++++
>  libc/vdso/vdso.version  |  3 +++
>  usr.manifest.skel       |  1 +
>  usr_nozfs.manifest.skel |  1 +
>  6 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 libc/vdso/vdso.c
>  create mode 100644 libc/vdso/vdso.version
>
> diff --git a/Makefile b/Makefile
> index e294a03..5327708 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1836,6 +1836,11 @@ $(out)/libenviron.so: $(environ_sources)
>         $(makedir)
>          $(call quiet, $(CC) $(CFLAGS) -shared -o $(out)/libenviron.so
> $(environ_sources), CC libenviron.so)
>
> +$(out)/libvdso.so: libc/vdso/vdso.c libc/vdso/vdso.ld
>

If I understand correctly (?), you don't have vdso.ld any more, so it
shouldn't be on the dependency list. Maybe you meant vdso.version?
I wonder how this didn't fail to build because vdso.ld is missing?


> +       $(makedir)
> +       $(call quiet, $(CC) -c -fPIC -o $(out)/libvdso.o libc/vdso/vdso.c,
> CC libvdso.o)
> +       $(call quiet, $(LD) -shared -fPIC -o $(out)/libvdso.so
> $(out)/libvdso.o --version-script=libc/vdso/vdso.version, LINK libvdso.so)
> +
>  bootfs_manifest ?= bootfs.manifest.skel
>
>  # If parameter "bootfs_manifest" has been changed since the last make,
> @@ -1848,7 +1853,7 @@ $(bootfs_manifest_dep): phony
>         fi
>
>  $(out)/bootfs.bin: scripts/mkbootfs.py $(bootfs_manifest)
> $(bootfs_manifest_dep) $(tools:%=$(out)/%) \
> -               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so
> +               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so
> $(out)/libvdso.so
>         $(call quiet, olddir=`pwd`; cd $(out);
> $$olddir/scripts/mkbootfs.py -o bootfs.bin -d bootfs.bin.d -m
> $$olddir/$(bootfs_manifest) \
>                 -D jdkbase=$(jdkbase) -D gccbase=$(gccbase) -D \
>                 glibcbase=$(glibcbase) -D miscbase=$(miscbase), MKBOOTFS
> $@)
> diff --git a/bootfs.manifest.skel b/bootfs.manifest.skel
> index 9816e92..41d48b4 100644
> --- a/bootfs.manifest.skel
> +++ b/bootfs.manifest.skel
> @@ -1,4 +1,5 @@
>  [manifest]
> +/libvdso.so: libvdso.so
>  /libuutil.so: libuutil.so
>  /zpool.so: zpool.so
>  /libzfs.so: libzfs.so
> diff --git a/libc/vdso/vdso.c b/libc/vdso/vdso.c
> new file mode 100644
> index 0000000..9212321
> --- /dev/null
> +++ b/libc/vdso/vdso.c
> @@ -0,0 +1,18 @@
> +//#include "libc.h"
> +#include <time.h>
> +#include <sys/time.h>
> +
> +time_t __vdso_time(time_t *tloc)
> +{
> +    return time(tloc);
> +}
> +
> +int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
> +{
> +    return gettimeofday(tv, tz);
> +}
> +
> +int __vdso_clock_gettime(clockid_t clk_id, struct timespec *tp)
> +{
> +    return clock_gettime(clk_id, tp);
> +}
> diff --git a/libc/vdso/vdso.version b/libc/vdso/vdso.version
> new file mode 100644
> index 0000000..a98ad1a
> --- /dev/null
> +++ b/libc/vdso/vdso.version
> @@ -0,0 +1,3 @@
> +LINUX_2.6 {
> +global: *;
> +};
> diff --git a/usr.manifest.skel b/usr.manifest.skel
> index 583bdfe..159b73d 100644
> --- a/usr.manifest.skel
> +++ b/usr.manifest.skel
> @@ -1,5 +1,6 @@
>  [manifest]
>  /libenviron.so: libenviron.so
> +/libvdso.so: libvdso.so
>  /zpool.so: zpool.so
>  /libzfs.so: libzfs.so
>  /libuutil.so: libuutil.so
> diff --git a/usr_nozfs.manifest.skel b/usr_nozfs.manifest.skel
> index a7d4731..ce051af 100644
> --- a/usr_nozfs.manifest.skel
> +++ b/usr_nozfs.manifest.skel
> @@ -1,5 +1,6 @@
>  [manifest]
>  /libenviron.so: libenviron.so
> +/libvdso.so: libvdso.so
>  /tools/mount-nfs.so: tools/mount/mount-nfs.so
>  /tools/umount.so: tools/mount/umount.so
>  /usr/lib/libgcc_s.so.1: %(gccbase)s/lib64/libgcc_s.so.1
> --
> 2.7.4
>
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to