aboutsummaryrefslogtreecommitdiff
path: root/dyngen.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-03-17 23:46:04 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-03-17 23:46:04 +0000
commitbc51c5c989c12b3936b78c5772a3308629a7484c (patch)
tree73f24550783bf7685add8e5828ffd28815759c7f /dyngen.c
parent5069146392ab358b106ed6a7a05440c69924448d (diff)
initial x86-64 host support (Gwenole Beauchesne)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@670 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'dyngen.c')
-rw-r--r--dyngen.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dyngen.c b/dyngen.c
index 89e98245b6..7c1c0e8aed 100644
--- a/dyngen.c
+++ b/dyngen.c
@@ -37,6 +37,13 @@
#define elf_check_arch(x) ( ((x) == EM_386) || ((x) == EM_486) )
#undef ELF_USES_RELOCA
+#elif defined(HOST_AMD64)
+
+#define ELF_CLASS ELFCLASS64
+#define ELF_ARCH EM_X86_64
+#define elf_check_arch(x) ((x) == EM_X86_64)
+#define ELF_USES_RELOCA
+
#elif defined(HOST_PPC)
#define ELF_CLASS ELFCLASS32
@@ -446,6 +453,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
start_offset = offset;
switch(ELF_ARCH) {
case EM_386:
+ case EM_X86_64:
{
int len;
len = p_end - p_start;
@@ -766,6 +774,41 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
}
}
}
+#elif defined(HOST_AMD64)
+ {
+ char name[256];
+ int type;
+ int addend;
+ for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
+ if (rel->r_offset >= start_offset &&
+ rel->r_offset < start_offset + copy_size) {
+ sym_name = strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
+ if (strstart(sym_name, "__op_param", &p)) {
+ snprintf(name, sizeof(name), "param%s", p);
+ } else {
+ snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
+ }
+ type = ELF32_R_TYPE(rel->r_info);
+ addend = rel->r_addend;
+ switch(type) {
+ case R_X86_64_32:
+ fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (uint32_t)%s + %d;\n",
+ rel->r_offset - start_offset, name, addend);
+ break;
+ case R_X86_64_32S:
+ fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (int32_t)%s + %d;\n",
+ rel->r_offset - start_offset, name, addend);
+ break;
+ case R_X86_64_PC32:
+ fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = %s - (long)(gen_code_ptr + %d) + %d;\n",
+ rel->r_offset - start_offset, name, rel->r_offset - start_offset, addend);
+ break;
+ default:
+ error("unsupported AMD64 relocation (%d)", type);
+ }
+ }
+ }
+ }
#elif defined(HOST_PPC)
{
char name[256];