Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Forward unknown syscalls to the libc syscall function.
Browse files Browse the repository at this point in the history
  • Loading branch information
rschatz committed Jul 2, 2018
1 parent cd19c65 commit fe84bba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates.
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
*
* All rights reserved.
*
Expand Down Expand Up @@ -334,3 +334,7 @@ pid_t __sulong_posix_getpgid(pid_t pid)
{
CALL(pid_t, getpgid, pid);
}

long __sulong_posix_syscall(long number, long rdi, long rsi, long rdx, long r10, long r8, long r9) {
CALL(long, syscall, number, rdi, rsi, rdx, r10, r8, r9);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates.
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
*
* All rights reserved.
*
Expand Down Expand Up @@ -29,14 +29,18 @@
*/
package com.oracle.truffle.llvm.nodes.asm.syscall;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.llvm.nodes.asm.syscall.posix.LLVMAMD64PosixCallNode;
import com.oracle.truffle.llvm.nodes.asm.syscall.posix.LLVMAMD64PosixCallNodeGen;
import com.oracle.truffle.llvm.runtime.memory.LLVMSyscallOperationNode;

public class LLVMAMD64UnknownSyscallNode extends LLVMSyscallOperationNode {
private final int nr;

public LLVMAMD64UnknownSyscallNode(int nr) {
private final long nr;
@Child private LLVMAMD64PosixCallNode syscall;

public LLVMAMD64UnknownSyscallNode(long nr) {
this.nr = nr;
this.syscall = LLVMAMD64PosixCallNodeGen.create("syscall", "(SINT64, POINTER, POINTER, POINTER, POINTER, POINTER, POINTER):SINT64", 1);
}

@Override
Expand All @@ -46,7 +50,6 @@ public final String getName() {

@Override
public long execute(Object rdi, Object rsi, Object rdx, Object r10, Object r8, Object r9) {
CompilerDirectives.transferToInterpreter();
throw new RuntimeException("unknown syscall " + nr);
return (long) syscall.execute(nr, rdi, rsi, rdx, r10, r8, r9);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public LLVMSyscallOperationNode createSyscallNode(long index) {
case LLVMAMD64Syscall.SYS_pipe2:
return LLVMAMD64SyscallPipe2NodeGen.create();
default:
return new LLVMAMD64UnknownSyscallNode((int) index);
return new LLVMAMD64UnknownSyscallNode(index);
}
}
}

0 comments on commit fe84bba

Please sign in to comment.