summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c4
-rw-r--r--linux-user/main.c75
-rw-r--r--linux-user/strace.c1
-rw-r--r--linux-user/syscall.c13
4 files changed, 86 insertions, 7 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 8b17c0e..7be6e71 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2001,9 +2001,13 @@ static void load_elf_image(const char *image_name, int image_fd,
info->brk = info->end_code;
}
+#if defined(CONFIG_LLVM)
+ load_symbols(ehdr, image_fd, load_bias);
+#else
if (qemu_log_enabled()) {
load_symbols(ehdr, image_fd, load_bias);
}
+#endif
close(image_fd);
return;
diff --git a/linux-user/main.c b/linux-user/main.c
index 8acfe0f..0f67ad4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -33,11 +33,12 @@
#include "qemu/timer.h"
#include "qemu/envlist.h"
#include "elf.h"
+#include "hqemu.h"
char *exec_path;
int singlestep;
-static const char *filename;
+const char *filename;
static const char *argv0;
static int gdbstub_port;
static envlist_t *envlist;
@@ -105,7 +106,10 @@ static int pending_cpus;
/* Make sure everything is in a consistent state for calling fork(). */
void fork_start(void)
{
- qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock);
+#if defined(CONFIG_LLVM)
+ llvm_fork_start();
+#endif
+ qemu_mutex_lock(&tcg_ctx.tb_ctx->tb_lock);
pthread_mutex_lock(&exclusive_lock);
mmap_fork_start();
}
@@ -127,12 +131,15 @@ void fork_end(int child)
pthread_mutex_init(&cpu_list_mutex, NULL);
pthread_cond_init(&exclusive_cond, NULL);
pthread_cond_init(&exclusive_resume, NULL);
- qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock);
+ qemu_mutex_init(&tcg_ctx.tb_ctx->tb_lock);
gdbserver_fork(thread_cpu);
} else {
pthread_mutex_unlock(&exclusive_lock);
- qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
+ qemu_mutex_unlock(&tcg_ctx.tb_ctx->tb_lock);
}
+#if defined(CONFIG_LLVM)
+ llvm_fork_end(child);
+#endif
}
/* Wait for pending exclusive operations to complete. The exclusive lock
@@ -276,6 +283,9 @@ void cpu_loop(CPUX86State *env)
abi_ulong pc;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_x86_exec(cs);
@@ -670,6 +680,9 @@ void cpu_loop(CPUARMState *env)
target_siginfo_t info;
uint32_t addr;
+ copy_tcg_context();
+ optimization_init(env);
+
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_arm_exec(cs);
@@ -1001,6 +1014,9 @@ void cpu_loop(CPUARMState *env)
int trapnr, sig;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
for (;;) {
cpu_exec_start(cs);
trapnr = cpu_arm_exec(cs);
@@ -1083,6 +1099,9 @@ void cpu_loop(CPUUniCore32State *env)
unsigned int n, insn;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
for (;;) {
cpu_exec_start(cs);
trapnr = uc32_cpu_exec(cs);
@@ -1284,6 +1303,9 @@ void cpu_loop (CPUSPARCState *env)
abi_long ret;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_sparc_exec(cs);
@@ -1564,6 +1586,9 @@ void cpu_loop(CPUPPCState *env)
int trapnr;
target_ulong ret;
+ copy_tcg_context();
+ optimization_init(env);
+
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_ppc_exec(cs);
@@ -2416,6 +2441,9 @@ void cpu_loop(CPUMIPSState *env)
unsigned int syscall_num;
# endif
+ copy_tcg_context();
+ optimization_init(env);
+
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_mips_exec(cs);
@@ -2653,6 +2681,9 @@ void cpu_loop(CPUOpenRISCState *env)
CPUState *cs = CPU(openrisc_env_get_cpu(env));
int trapnr, gdbsig;
+ copy_tcg_context();
+ optimization_init(env);
+
for (;;) {
cpu_exec_start(cs);
trapnr = cpu_openrisc_exec(cs);
@@ -2743,6 +2774,9 @@ void cpu_loop(CPUSH4State *env)
int trapnr, ret;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_sh4_exec(cs);
@@ -2805,6 +2839,9 @@ void cpu_loop(CPUCRISState *env)
int trapnr, ret;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_cris_exec(cs);
@@ -2866,6 +2903,9 @@ void cpu_loop(CPUMBState *env)
int trapnr, ret;
target_siginfo_t info;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_mb_exec(cs);
@@ -2971,6 +3011,9 @@ void cpu_loop(CPUM68KState *env)
target_siginfo_t info;
TaskState *ts = cs->opaque;
+ copy_tcg_context();
+ optimization_init(env);
+
for(;;) {
cpu_exec_start(cs);
trapnr = cpu_m68k_exec(cs);
@@ -3110,6 +3153,9 @@ void cpu_loop(CPUAlphaState *env)
target_siginfo_t info;
abi_long sysret;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_alpha_exec(cs);
@@ -3298,6 +3344,9 @@ void cpu_loop(CPUS390XState *env)
target_siginfo_t info;
target_ulong addr;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_s390x_exec(cs);
@@ -3602,6 +3651,9 @@ void cpu_loop(CPUTLGState *env)
CPUState *cs = CPU(tilegx_env_get_cpu(env));
int trapnr;
+ copy_tcg_context();
+ optimization_init(env);
+
while (1) {
cpu_exec_start(cs);
trapnr = cpu_tilegx_exec(cs);
@@ -3711,7 +3763,7 @@ CPUArchState *cpu_copy(CPUArchState *env)
cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
}
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
- cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL);
+ cpu_watchpoint_insert(new_cpu, wp->addr, wp->len, wp->flags, NULL);
}
return new_env;
@@ -4009,6 +4061,12 @@ static void usage(int exitcode)
"Note that if you provide several changes to a single variable\n"
"the last change will stay in effect.\n");
+#if defined(CONFIG_LLVM)
+ printf("\n\nHQEMU ");
+ fflush(stdout);
+ hqemu_help();
+#endif
+
exit(exitcode);
}
@@ -4324,7 +4382,11 @@ int main(int argc, char **argv, char **envp)
/* Now that we've loaded the binary, GUEST_BASE is fixed. Delay
generating the prologue until now so that the prologue can take
the real value of GUEST_BASE into account. */
- tcg_prologue_init(&tcg_ctx);
+ tcg_prologue_init(&tcg_ctx_global);
+
+#if defined(CONFIG_LLVM)
+ llvm_init();
+#endif
#if defined(TARGET_I386)
env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
@@ -4663,6 +4725,7 @@ int main(int argc, char **argv, char **envp)
}
gdb_handlesig(cpu, 0);
}
+
cpu_loop(env);
/* never exits */
return 0;
diff --git a/linux-user/strace.c b/linux-user/strace.c
index ea6c1d2..69d5408 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/mman.h>
+#include <sys/sysmacros.h>
#include <unistd.h>
#include <sched.h>
#include "qemu.h"
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6c64ba6..030eb2a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -114,6 +114,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include "uname.h"
#include "qemu.h"
+#include "hqemu.h"
#define CLONE_NPTL_FLAGS2 (CLONE_SETTLS | \
CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)
@@ -4495,7 +4496,7 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
#endif /* defined(TARGET_I386) */
-#define NEW_STACK_SIZE 0x40000
+#define NEW_STACK_SIZE 0x80000
static pthread_mutex_t clone_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -5710,6 +5711,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
rcu_unregister_thread();
pthread_exit(NULL);
}
+
+ optimization_finalize((CPUArchState *)cpu_env);
+#if defined(CONFIG_LLVM)
+ llvm_finalize();
+#endif
+
#ifdef TARGET_GPROF
_mcleanup();
#endif
@@ -7615,6 +7622,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#ifdef __NR_exit_group
/* new thread calls */
case TARGET_NR_exit_group:
+ optimization_finalize((CPUArchState *)cpu_env);
+#if defined(CONFIG_LLVM)
+ llvm_finalize();
+#endif
#ifdef TARGET_GPROF
_mcleanup();
#endif
OpenPOWER on IntegriCloud