Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vdso fast syscall compatibility library
Some application runtimes like Golang need libvdso in order to lookup time. More specifically on startup Golang gets passed in address of libvdso library so that it can lookup addresses of these 3 function symbols - __vdso_time, __vdso_gettimeofday and __vdso_clock_gettime. For details please look at https://github.com/golang/go/blob/master/src/runtime/vdso_linux.go and https://github.com/golang/go/blob/master/src/runtime/vdso_linux_amd64.go. This patch adds implementation of 3 required functions (vdso.c) and modifies Makefile and bootstrap skeleton files to produce libvdso.so and add it the user image. One of the follow up patches will actually add the logic to pass base address of libvdso ELF as part of auxv when initializing Golang shared object. The alternative to having separate libvdso.so would be linking the __vdso_* functions directly to the loader.elf and passing its base address to auxv but unfortunately it would not work for following reasons: 1. For some reason (possibly a bug) the base address of loader.elf (per object::base()) is 0x0000000000000000 instead of expected 0x0000000000200000x and Golang guards against address 0. 2. Even if the above was not an issue there is high probability that Golang would have not been able to find symbols of __vdso_* functions from loader.elf given that it directly reads content of of the ELF to parse and find the symbols at binary level (it does not use standard dlopen() and dlsym()). The content of this patch was authored by Benoit Canet. Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com> Message-Id: <1521312416-29803-1-git-send-email-jwkozaczuk@gmail.com>
- Loading branch information
Showing
6 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[manifest] | ||
/libvdso.so: libvdso.so | ||
/libuutil.so: libuutil.so | ||
/zpool.so: zpool.so | ||
/libzfs.so: libzfs.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LINUX_2.6 { | ||
global: *; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters