50 lines · plain
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * thunks_32.S - assembly helpers for mixed-bitness code4 * Copyright (c) 2015 Denys Vlasenko5 *6 * These are little helpers that make it easier to switch bitness on7 * the fly.8 */9 10 .text11 .code3212 13 .global call64_from_3214 .type call32_from_64, @function15 16 // 4(%esp): function to call17call64_from_32:18 // Fetch function address19 mov 4(%esp), %eax20 21 // Save registers which are callee-clobbered by 64-bit ABI22 push %ecx23 push %edx24 push %esi25 push %edi26 27 // Switch to long mode28 jmp $0x33,$1f291: .code6430 31 // Call the function32 call *%rax33 34 // Switch to compatibility mode35 push $0x23 /* USER32_CS */36 .code32; push $1f; .code64 /* hack: can't have X86_64_32S relocation in 32-bit ELF */37 lretq381: .code3239 40 pop %edi41 pop %esi42 pop %edx43 pop %ecx44 45 ret46 47.size call64_from_32, .-call64_from_3248 49.section .note.GNU-stack,"",%progbits50