brintos

brintos / linux-shallow public Read only

0
0
Text · 916 B · a2d47d8 Raw
62 lines · plain
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * thunks.S - assembly helpers for mixed-bitness code4 * Copyright (c) 2015 Andrew Lutomirski5 *6 * These are little helpers that make it easier to switch bitness on7 * the fly.8 */9 10	.text11 12	.global call32_from_6413	.type call32_from_64, @function14call32_from_64:15	// rdi: stack to use16	// esi: function to call17 18	// Save registers19	pushq %rbx20	pushq %rbp21	pushq %r1222	pushq %r1323	pushq %r1424	pushq %r1525	pushfq26 27	// Switch stacks28	mov %rsp,(%rdi)29	mov %rdi,%rsp30 31	// Switch to compatibility mode32	pushq $0x23  /* USER32_CS */33	pushq $1f34	lretq35 361:37	.code3238	// Call the function39	call *%esi40	// Switch back to long mode41	jmp $0x33,$1f42	.code6443 441:45	// Restore the stack46	mov (%rsp),%rsp47 48	// Restore registers49	popfq50	popq %r1551	popq %r1452	popq %r1353	popq %r1254	popq %rbp55	popq %rbx56 57	ret58 59.size call32_from_64, .-call32_from_6460 61.section .note.GNU-stack,"",%progbits62