2 * thunks_32.S - assembly helpers for mixed-bitness code
3 * Copyright (c) 2015 Denys Vlasenko
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * These are little helpers that make it easier to switch bitness on
21 .global call64_from_32
22 .type call32_from_64, @function
24 // 4(%esp): function to call
26 // Fetch function address
29 // Save registers which are callee-clobbered by 64-bit ABI
35 // Switch to long mode
42 // Switch to compatibility mode
43 push $0x23 /* USER32_CS */
44 .code32; push $1f; .code64 /* hack: can't have X86_64_32S relocation in 32-bit ELF */
55 .size call64_from_32, .-call64_from_32