OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 IDENTIFIER(NaClSyscallSeg): | 45 IDENTIFIER(NaClSyscallSeg): |
46 /* | 46 /* |
47 * As far as we know, glibc-derived code always explicitly clears | 47 * As far as we know, glibc-derived code always explicitly clears |
48 * (or sets) the direction flag, so this is an issue only for Windows. | 48 * (or sets) the direction flag, so this is an issue only for Windows. |
49 */ | 49 */ |
50 | 50 |
51 cld | 51 cld |
52 xor %eax, %eax | 52 xor %eax, %eax |
53 mov %gs, %ax | 53 mov %gs, %ax |
54 shr $3, %eax | 54 shr $3, %eax |
55 #ifdef __PIC__ | |
56 mov IDENTIFIER(nacl_user)@GOTPCREL(%rip), %edx | |
Mark Seaborn
2010/02/15 14:45:49
I'm not sure if this is correct.
It might need an
| |
57 lea 0(%edx,%eax,4), %edx | |
58 #else | |
55 lea IDENTIFIER(nacl_user)(,%eax,4), %edx | 59 lea IDENTIFIER(nacl_user)(,%eax,4), %edx |
60 #endif | |
56 | 61 |
57 /* check NaClThreadContext in sel_rt.h for the offsets */ | 62 /* check NaClThreadContext in sel_rt.h for the offsets */ |
58 movl 0(%edx), %edx | 63 movl 0(%edx), %edx |
59 movl %ebx, 0x0(%edx) | 64 movl %ebx, 0x0(%edx) |
60 movl %esi, 0x4(%edx) | 65 movl %esi, 0x4(%edx) |
61 movl %edi, 0x8(%edx) | 66 movl %edi, 0x8(%edx) |
62 movl %ebp, 0x14(%edx) | 67 movl %ebp, 0x14(%edx) |
63 mov %rsp, 0x18(%edx) | 68 mov %rsp, 0x18(%edx) |
64 | 69 |
65 /* | 70 /* |
66 * load only the system segments; called code do not depend on | 71 * load only the system segments; called code do not depend on |
67 * any registers having particular values. we will clear/discard | 72 * any registers having particular values. we will clear/discard |
68 * caller-saved registers at system call return. | 73 * caller-saved registers at system call return. |
69 */ | 74 */ |
75 #ifdef __PIC__ | |
76 mov IDENTIFIER(nacl_sys)@GOTPCREL(%rip), %edx | |
77 lea 0(%edx,%eax,4), %edx | |
78 #else | |
70 lea IDENTIFIER(nacl_sys)(,%eax,4), %edx | 79 lea IDENTIFIER(nacl_sys)(,%eax,4), %edx |
80 #endif | |
71 mov 0(%edx), %edx | 81 mov 0(%edx), %edx |
72 /* | 82 /* |
73 * %cs and %ds already taken care of by NaCl_trampoline_seg_code | 83 * %cs and %ds already taken care of by NaCl_trampoline_seg_code |
74 * | 84 * |
75 * %ebx need not be saved/restored even if -fpic were used, since | 85 * %ebx need not be saved/restored even if -fpic were used, since |
76 * in that case %ebx is initialized on fn entry. | 86 * in that case %ebx is initialized on fn entry. |
77 */ | 87 */ |
78 mov 0x2c(%edx), %fs | 88 mov 0x2c(%edx), %fs |
79 mov 0x2e(%edx), %gs | 89 mov 0x2e(%edx), %gs |
80 | 90 |
81 mov 0x18(%edx), %edx /* sp */ | 91 mov 0x18(%edx), %edx /* sp */ |
82 mov %ecx, %ss /* disable intr */ | 92 mov %ecx, %ss /* disable intr */ |
83 mov %rdx, %rsp | 93 mov %rdx, %rsp |
84 push %rax | 94 push %rax |
95 #ifdef __PIC__ | |
96 call IDENTIFIER(NaClSyscallCSegHook)@PLT | |
Mark Seaborn
2010/02/15 14:45:49
Calling via the PLT is not necessary to make this
| |
97 #else | |
85 call IDENTIFIER(NaClSyscallCSegHook) | 98 call IDENTIFIER(NaClSyscallCSegHook) |
99 #endif | |
86 /* | 100 /* |
87 * If stack usage in the above code changes, modify initial %esp | 101 * If stack usage in the above code changes, modify initial %esp |
88 * computation -- see nacl_switch_to_app.c:NaClStartThreadInApp. | 102 * computation -- see nacl_switch_to_app.c:NaClStartThreadInApp. |
89 */ | 103 */ |
90 hlt | 104 hlt |
91 /* noret */ | 105 /* noret */ |
OLD | NEW |