Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / arch / x86_32 / tramp_32.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 /*
12  * Trampoline to transfer control from native client module to
13  * sel_ldr's NaClSyscallSeg residing in the same address space
14  */
15
16 #include "native_client/src/trusted/service_runtime/nacl_config.h"
17
18         /*
19          * This is code, but it is not code that is actually part of the
20          * program/library being linked.  Marking it as read-only data
21          * instead ensures that nothing like linker code-rewriting will
22          * be applied to this code.
23          */
24         NACL_RODATA
25
26 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_seg_code):
27         lcall   $0xcafe, $0xdeadbeef  /* orig-cs, thunk */
28 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_tramp_cseg_patch):
29         hlt
30 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_trampoline_seg_end):
31
32
33 DEFINE_GLOBAL_HIDDEN_LOCATION(NaClPcrelThunk):
34         movl    $0xdeadbeef, %eax  /* known okay ds */
35 DEFINE_GLOBAL_HIDDEN_LOCATION(NaClPcrelThunk_dseg_patch):
36         mov     %ax, %ds  /* disable data sandbox for this thread */
37         movl    $0xdeadbeef, %ecx  /* nacl_user */
38 DEFINE_GLOBAL_HIDDEN_LOCATION(NaClPcrelThunk_globals_patch):
39         /*
40          * This is a regular PC-relative jump.  The displacement will be
41          * patched in.  Using an explicit opcode with the largest possible
42          * displacement here rather than "jmp" ensures that no too-clever
43          * assembler or linker could ever produce a different opcode with a
44          * smaller displacement.
45          */
46         .byte 0xe9, 0xff, 0xff, 0xff, 0x7f
47 DEFINE_GLOBAL_HIDDEN_LOCATION(NaClPcrelThunk_end):