Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / x86_64 / tramp_64.S
1 /*
2  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * NaCl Simple/secure ELF loader (NaCl SEL).
9  */
10
11 #include "native_client/src/trusted/service_runtime/nacl_config.h"
12
13         /*
14          * This is code, but it is not code that is actually part of the
15          * program/library being linked.  Marking it as read-only data
16          * instead ensures that nothing like linker code-rewriting will
17          * be applied to this code.
18          */
19         NACL_RODATA
20
21 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_code):
22         /*
23          * Write a value onto the stack which is used to calculate the
24          * syscall number.
25          */
26         movl $0xdeadbeef, -8(%rsp)
27 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_tramp_addr):
28         mov $0xdeadbeefcafebabe, %rax
29 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_call_target):
30         /*
31          * Fetch the address of NaClSyscallSeg (or other syscall
32          * routine) and jump to it.  We store the address in a
33          * location outside the sandbox so as not to defeat ASLR by
34          * leaking address space layout to untrusted code.
35          */
36         jmp *(%rax)
37         hlt
38 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_code_end):