diff --git a/LibOS/shim/include/arch/x86_64/shim_internal-arch.h b/LibOS/shim/include/arch/x86_64/shim_internal-arch.h index d5c33c27..77a99fa0 100644 --- a/LibOS/shim/include/arch/x86_64/shim_internal-arch.h +++ b/LibOS/shim/include/arch/x86_64/shim_internal-arch.h @@ -26,4 +26,14 @@ static_always_inline void* current_stack(void) { return _rsp; } +#define CALL_ELF_ENTRY(ENTRY, ARGCP) \ + __asm__ volatile( \ + "pushq $0\r\n" \ + "popfq\r\n" \ + "movq %%rbx, %%rsp\r\n" \ + "jmp *%%rax\r\n" \ + : \ + : "a"(ENTRY), "b"(ARGCP), "d"(0) \ + : "memory", "cc") + #endif /* _SHIM_INTERNAL_ARCH_H_ */ diff --git a/LibOS/shim/src/elf/shim_rtld.c b/LibOS/shim/src/elf/shim_rtld.c index eef9e469..3fc34b02 100644 --- a/LibOS/shim/src/elf/shim_rtld.c +++ b/LibOS/shim/src/elf/shim_rtld.c @@ -1592,18 +1592,8 @@ noreturn void execute_elf_object(struct shim_handle* exec, int* argcp, const cha shim_tcb_t* tcb = shim_get_tcb(); __enable_preempt(tcb); -#if defined(__x86_64__) - __asm__ volatile( - "pushq $0\r\n" - "popfq\r\n" - "movq %%rbx, %%rsp\r\n" - "jmp *%%rax\r\n" - : - : "a"(entry), "b"(argcp), "d"(0) - : "memory", "cc"); -#else -#error "architecture not supported" -#endif + CALL_ELF_ENTRY(entry, argcp); + while (true) /* nothing */; }