1// Copyright 2017 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "asm.h" 6#include "setjmp_impl.h" 7#include <zircon/tls.h> 8 9ENTRY(setjmp) 10 11 // Copy the values that need mangling into temporaries. 12 mov (%rsp), %rax // PC 13 mov %rsp, %rcx // SP 14 mov %rbp, %rdx // FP 15 mov %fs:ZX_TLS_UNSAFE_SP_OFFSET, %rsi // Unsafe SP 16 17 // Store all the vanilla callee-saves registers. 18 mov %rbx, 8*JB_RBX(%rdi) 19 mov %r12, 8*JB_R12(%rdi) 20 mov %r13, 8*JB_R13(%rdi) 21 mov %r14, 8*JB_R14(%rdi) 22 mov %r15, 8*JB_R15(%rdi) 23 24 // Mangle each temporary. 25 xor __setjmp_manglers+8*JB_PC(%rip), %rax 26 xor __setjmp_manglers+8*JB_SP(%rip), %rcx 27 xor __setjmp_manglers+8*JB_FP(%rip), %rdx 28 xor __setjmp_manglers+8*JB_USP(%rip), %rsi 29 30 // Store the mangled values. 31 mov %rax, 8*JB_PC(%rdi) 32 mov %rcx, 8*JB_SP(%rdi) 33 mov %rdx, 8*JB_FP(%rdi) 34 mov %rsi, 8*JB_USP(%rdi) 35 36 // %rax = 0 37 xor %eax, %eax 38 39 ret 40 41END(setjmp) 42 43ALIAS(setjmp, _setjmp) 44WEAK_ALIAS(setjmp, sigsetjmp) 45