mirror of
https://git.freebsd.org/ports.git
synced 2025-06-29 00:20:40 -04:00
- Update emulators/qemu-devel to 1.4.0 with preliminary bsd-user patches. Thanx to: sson, cognet, and others for much improved bsd-user support - it now runs at least quite a few mips64 and single-threaded arm binaries, see: https://wiki.freebsd.org/QemuUserModeHowTo
92 lines
2.8 KiB
Text
92 lines
2.8 KiB
Text
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
|
|
index 8abb1dd..c2c3a65 100644
|
|
--- a/bsd-user/elfload.c
|
|
+++ b/bsd-user/elfload.c
|
|
@@ -798,6 +798,7 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct bsd_binprm *bprm,
|
|
p -= roundup(execpath_len, sizeof(abi_ulong));
|
|
/* XXX - check return value of memcpy_to_target() */
|
|
memcpy_to_target(p, execpath, execpath_len);
|
|
+ strlcpy(target_proc_pathname, execpath, execpath_len);
|
|
}
|
|
|
|
/* Add canary for SSP. */
|
|
diff --git a/bsd-user/main.c b/bsd-user/main.c
|
|
index bb614de..b6aaa7e 100644
|
|
--- a/bsd-user/main.c
|
|
+++ b/bsd-user/main.c
|
|
@@ -62,6 +62,7 @@ unsigned long x86_stack_size = 512 * 1024;
|
|
|
|
static void save_proc_pathname(void);
|
|
char qemu_proc_pathname[PATH_MAX];
|
|
+char target_proc_pathname[PATH_MAX];
|
|
|
|
#ifdef __FreeBSD__
|
|
static void
|
|
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
|
|
index 110b54e..d51f50c 100644
|
|
--- a/bsd-user/qemu.h
|
|
+++ b/bsd-user/qemu.h
|
|
@@ -224,6 +224,7 @@ void mmap_fork_end(int child);
|
|
/* main.c */
|
|
extern unsigned long x86_stack_size;
|
|
extern char qemu_proc_pathname[];
|
|
+extern char target_proc_pathname[];
|
|
|
|
/* user access */
|
|
|
|
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
|
|
index 74b5c86..636083a 100644
|
|
--- a/bsd-user/syscall.c
|
|
+++ b/bsd-user/syscall.c
|
|
@@ -485,8 +485,6 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol
|
|
abi_ulong oldlen = 0;
|
|
int32_t *snamep = g_malloc(sizeof(int32_t) * namelen), *p, *q, i;
|
|
uint32_t kind = 0;
|
|
- abi_ulong argv, argv0;
|
|
- char *fullpath = NULL;
|
|
|
|
if (oldlenp)
|
|
if (get_user_ual(oldlen, oldlenp))
|
|
@@ -533,30 +531,14 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol
|
|
case KERN_PROC:
|
|
switch(snamep[2]) {
|
|
case KERN_PROC_PATHNAME:
|
|
- if (get_user_ual(argv, TARGET_PS_STRINGS)) {
|
|
- ret = -TARGET_EFAULT;
|
|
- goto out;
|
|
- }
|
|
- if (get_user_ual(argv0, argv)) {
|
|
- ret = -TARGET_EFAULT;
|
|
- goto out;
|
|
- }
|
|
-
|
|
- fullpath = realpath(g2h(argv0), NULL);
|
|
- if (NULL == fullpath)
|
|
- fullpath = (char *)g2h(argv0);
|
|
- holdlen = strlen(fullpath) + 1;
|
|
+ holdlen = strlen(target_proc_pathname) + 1;
|
|
if (holdp) {
|
|
if (oldlen < holdlen) {
|
|
ret = -TARGET_EINVAL;
|
|
goto out;
|
|
}
|
|
- if (!access_ok(VERIFY_WRITE, argv0,
|
|
- holdlen)) {
|
|
- ret = -TARGET_EFAULT;
|
|
- goto out;
|
|
- }
|
|
- strlcpy(holdp, fullpath, oldlen);
|
|
+ strlcpy(holdp, target_proc_pathname,
|
|
+ oldlen);
|
|
}
|
|
ret = 0;
|
|
goto out;
|
|
@@ -597,8 +579,6 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol
|
|
#endif
|
|
|
|
out:
|
|
- if (fullpath)
|
|
- free(fullpath);
|
|
if (oldlenp)
|
|
put_user_ual(holdlen, oldlenp);
|
|
unlock_user(hnamep, namep, 0);
|