aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi64/cloudabi64_module.c
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2016-08-10 21:02:41 +0000
committerEd Schouten <ed@FreeBSD.org>2016-08-10 21:02:41 +0000
commit13b4b4df987d8f05c2cd5813cfe05db953c37c9e (patch)
tree6f1539b3db69da365d8d1ef2df5cbd14c5892af6 /sys/compat/cloudabi64/cloudabi64_module.c
parent6178f8e8a6ab27d49d4d0c5cbd05be4ca2d140f7 (diff)
downloadsrc-13b4b4df987d8f05c2cd5813cfe05db953c37c9e.tar.gz
src-13b4b4df987d8f05c2cd5813cfe05db953c37c9e.zip
Provide the CloudABI vDSO to its executables.
CloudABI executables already provide support for passing in vDSOs. This functionality is used by the emulator for OS X to inject system call handlers. On FreeBSD, we could use it to optimize calls to gettimeofday(), etc. Though I don't have any plans to optimize any system calls right now, let's go ahead and already pass in a vDSO. This will allow us to simplify the executables, as the traditional "syscall" shims can be removed entirely. It also means that we gain more flexibility with regards to adding and removing system calls. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D7438
Notes
Notes: svn path=/head/; revision=303941
Diffstat (limited to 'sys/compat/cloudabi64/cloudabi64_module.c')
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c
index 246a887105cb..da1ea1149a4b 100644
--- a/sys/compat/cloudabi64/cloudabi64_module.c
+++ b/sys/compat/cloudabi64/cloudabi64_module.c
@@ -38,8 +38,13 @@ __FBSDID("$FreeBSD$");
#include <contrib/cloudabi/cloudabi64_types.h>
+#include <compat/cloudabi/cloudabi_util.h>
+
#include <compat/cloudabi64/cloudabi64_util.h>
+extern char _binary_cloudabi64_vdso_o_start[];
+extern char _binary_cloudabi64_vdso_o_end[];
+
register_t *
cloudabi64_copyout_strings(struct image_params *imgp)
{
@@ -107,6 +112,8 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_SYSINFO_EHDR,
+ imgp->proc->p_sysent->sv_shared_page_base),
#undef VAL
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
@@ -127,6 +134,9 @@ cloudabi64_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
+ cloudabi_vdso_init(cloudabi64_brand.sysvec,
+ _binary_cloudabi64_vdso_o_start,
+ _binary_cloudabi64_vdso_o_end);
if (elf64_insert_brand_entry(&cloudabi64_brand) < 0) {
printf("Failed to add CloudABI ELF brand handler\n");
return (EINVAL);
@@ -139,6 +149,7 @@ cloudabi64_modevent(module_t mod, int type, void *data)
printf("Failed to remove CloudABI ELF brand handler\n");
return (EINVAL);
}
+ cloudabi_vdso_destroy(cloudabi64_brand.sysvec);
return (0);
default:
return (EOPNOTSUPP);