Chromium Code Reviews| Index: sandbox/linux/seccomp-bpf/syscall.cc |
| diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc |
| index bc6461f11773b245919596162eb4230162be56a4..cf1c50d403b7aa4c11bcc9674ee2f47db2b86c3b 100644 |
| --- a/sandbox/linux/seccomp-bpf/syscall.cc |
| +++ b/sandbox/linux/seccomp-bpf/syscall.cc |
| @@ -190,12 +190,15 @@ asm(// We need to be able to tell the kernel exactly where we made a |
| "9:.size SyscallAsm, 9b-SyscallAsm\n" |
| #elif defined(__mips__) |
| ".text\n" |
| + ".option pic2\n" |
| ".align 4\n" |
| + ".global SyscallAsm\n" |
| ".type SyscallAsm, @function\n" |
| "SyscallAsm:.ent SyscallAsm\n" |
| ".frame $sp, 40, $ra\n" |
| ".set push\n" |
| ".set noreorder\n" |
| + ".cpload $t9\n" |
| "addiu $sp, $sp, -40\n" |
| "sw $ra, 36($sp)\n" |
| // Check if "v0" is negative. If so, do not attempt to make a |
| @@ -204,7 +207,8 @@ asm(// We need to be able to tell the kernel exactly where we made a |
| // used as a marker that BPF code inspects. |
| "bgez $v0, 1f\n" |
| " nop\n" |
| - "la $v0, 2f\n" |
| + "lw $v0, %got(2f)($gp)\n" |
|
mdempsky
2016/04/28 16:02:13
Please add a comment so someone doesn't come along
lmilko
2016/05/04 15:13:05
Done.
|
| + "addiu $v0, $v0, %lo(2f)\n" |
| "b 2f\n" |
| " nop\n" |
| // On MIPS first four arguments go to registers a0 - a3 and any |
| @@ -262,6 +266,10 @@ asm(// We need to be able to tell the kernel exactly where we made a |
| extern "C" { |
| intptr_t SyscallAsm(intptr_t nr, const intptr_t args[6]); |
| } |
| +#elif defined(__mips__) |
| +extern "C" { |
| +intptr_t SyscallAsm(intptr_t nr, const intptr_t args[8]); |
| +} |
| #endif |
| } // namespace |
| @@ -395,20 +403,21 @@ intptr_t Syscall::SandboxSyscallRaw(int nr, |
| const intptr_t* args, |
| intptr_t* err_ret) { |
| register intptr_t ret __asm__("v0") = nr; |
| + register intptr_t syscallasm __asm__("t9") = (intptr_t) &SyscallAsm; |
| // a3 register becomes non zero on error. |
| register intptr_t err_stat __asm__("a3") = 0; |
| { |
| register const intptr_t* data __asm__("a0") = args; |
| asm volatile( |
| - "la $t9, SyscallAsm\n" |
| "jalr $t9\n" |
| " nop\n" |
| : "=r"(ret), "=r"(err_stat) |
| : "0"(ret), |
| - "r"(data) |
| + "r"(data), |
| + "r"(syscallasm) |
| // a2 is in the clober list so inline assembly can not change its |
| // value. |
| - : "memory", "ra", "t9", "a2"); |
| + : "memory", "ra", "a2"); |
| } |
| // Set an error status so it can be used outside of this function |