From befbd5731ecca08f08780ee28a913d08ffb14656 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 6 Mar 2014 01:13:39 -0800 Subject: Fix host architecture for 64bit. Also, hack x86 assembler for use as a x86-64 trampoline compiler's assembler. Implement missing x86-64 quick resolution trampoline. Add x86-64 to the quick elf writer. Change-Id: I08216c67014a83492ada12898ab8000218ba7bb4 --- compiler/trampolines/trampoline_compiler.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'compiler/trampolines/trampoline_compiler.cc') diff --git a/compiler/trampolines/trampoline_compiler.cc b/compiler/trampolines/trampoline_compiler.cc index 32ae5583ac..3e13e44397 100644 --- a/compiler/trampolines/trampoline_compiler.cc +++ b/compiler/trampolines/trampoline_compiler.cc @@ -100,6 +100,23 @@ static const std::vector* CreateTrampoline(ThreadOffset offset) { } } // namespace x86 +namespace x86_64 { +static const std::vector* CreateTrampoline(ThreadOffset offset) { + UniquePtr assembler(static_cast(Assembler::Create(kX86_64))); + + // All x86 trampolines call via the Thread* held in gs. + __ gs()->jmp(x86::Address::Absolute(offset, true)); + __ int3(); + + size_t cs = assembler->CodeSize(); + UniquePtr > entry_stub(new std::vector(cs)); + MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); + assembler->FinalizeInstructions(code); + + return entry_stub.release(); +} +} // namespace x86_64 + const std::vector* CreateTrampoline(InstructionSet isa, EntryPointCallingConvention abi, ThreadOffset offset) { switch (isa) { @@ -110,6 +127,8 @@ const std::vector* CreateTrampoline(InstructionSet isa, EntryPointCalli return mips::CreateTrampoline(abi, offset); case kX86: return x86::CreateTrampoline(offset); + case kX86_64: + return x86_64::CreateTrampoline(offset); default: LOG(FATAL) << "Unknown InstructionSet: " << isa; return NULL; -- cgit v1.2.3