|
| 1 | +/* |
| 2 | + * Copyright (c) 2018, 2020 Ariadne Conill <[email protected]> |
| 3 | + * |
| 4 | + * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | + * purpose with or without fee is hereby granted, provided that the above |
| 6 | + * copyright notice and this permission notice appear in all copies. |
| 7 | + * |
| 8 | + * This software is provided 'as is' and without any warranty, express or |
| 9 | + * implied. In no event shall the authors be liable for any damages arising |
| 10 | + * from the use of this software. |
| 11 | + */ |
| 12 | + |
| 13 | +#include "defs.h" |
| 14 | + |
| 15 | +FUNC(libucontext_trampoline) |
| 16 | + /* get the proper context into position and test for NULL */ |
| 17 | + leal (%esp,%ebx,4), %esp |
| 18 | + cmpl $0, (%esp) |
| 19 | + |
| 20 | + /* restore global offset table, exit@plt and libucontext_setcontext@plt need this */ |
| 21 | + call __i686_get_pc_thunk_bx |
| 22 | + addl $_GLOBAL_OFFSET_TABLE_, %ebx |
| 23 | + |
| 24 | + /* if we have no linked context, lets get out of here */ |
| 25 | + je no_linked_context |
| 26 | + |
| 27 | + /* call setcontext to switch to the linked context */ |
| 28 | + call libucontext_setcontext@plt |
| 29 | + movl %eax, (%esp) |
| 30 | + |
| 31 | +no_linked_context: |
| 32 | + /* we are returning into a null context, it seems, so maybe we should exit */ |
| 33 | + call exit@plt |
| 34 | + |
| 35 | + /* something is really hosed, call hlt to force termination */ |
| 36 | + hlt |
| 37 | + |
| 38 | +__i686_get_pc_thunk_bx: |
| 39 | + mov (%esp), %ebx |
| 40 | + ret |
| 41 | +END(libucontext_trampoline) |
0 commit comments