system-calls

Golang: How to use syscall.Syscall on Linux?

て烟熏妆下的殇ゞ 提交于 2020-08-19 03:44:53
问题 There is a very nice description about loading a shared library and calling a function with the syscall package on Windows (https://github.com/golang/go/wiki/WindowsDLLs). However, the functions LoadLibrary and GetProcAddress that are used in this description are not available in the syscall package on Linux. I could not find documentation about how to do this on Linux (or Mac OS). Thanks for help 回答1: Linux syscalls are used directly without loading a library, exactly how depends on which

Difference between Syscall and Traps

ⅰ亾dé卋堺 提交于 2020-07-18 08:09:30
问题 I am wondering if there is any difference between the MIPS syscall and trap instructions. I can't find anything involving this, so I am not sure if there is a difference. Traps seem to just be a conditional syscall, but some clarifying can be helpful. 回答1: The SYSCALL and TRAP instructions both trigger exceptions, but the resulting exception is of a different type (SystemCall versus Trap), and the operating system will likely handle them differently. 回答2: A Trap is an exception switches to

Difference between Syscall and Traps

▼魔方 西西 提交于 2020-07-18 08:08:12
问题 I am wondering if there is any difference between the MIPS syscall and trap instructions. I can't find anything involving this, so I am not sure if there is a difference. Traps seem to just be a conditional syscall, but some clarifying can be helpful. 回答1: The SYSCALL and TRAP instructions both trigger exceptions, but the resulting exception is of a different type (SystemCall versus Trap), and the operating system will likely handle them differently. 回答2: A Trap is an exception switches to

Create new system-call in xv6 that returns data about an open files for all running processes

和自甴很熟 提交于 2020-06-29 04:32:16
问题 Im started to learn about xv6. And I'm trying to add a new system call that will print the list of open files for all running processes. It has to print pid of each process, its file descriptor number (0,1,2- for each pid), if the file is regular or piped and if the file is readable of writable. So I know is how to get the pid. Here is an example of a code: struct proc *p; sti(); acquire(&ptable.lock); cprintf("name \t pid \t type \t \n"); for (p=ptable.proc; p<&ptable.proc[NPROC]; p++){

Hello, world in assembly language with Linux system calls?

喜夏-厌秋 提交于 2020-06-23 18:05:10
问题 I know that int 0x80 is making interrupt in linux. But, I don't understand how this code works. Does it returning something? What $ - msg standing for? global _start section .data msg db "Hello, world!", 0x0a len equ $ - msg section .text _start: mov eax, 4 mov ebx, 1 mov ecx, msg mov edx, len int 0x80 ;What is this? mov eax, 1 mov ebx, 0 int 0x80 ;and what is this? 回答1: How does $ work in NASM, exactly? explains how $ - msg gets NASM to calculate the string length as an assemble-time

How syscall knows where to jump? [closed]

三世轮回 提交于 2020-06-12 04:42:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 11 months ago . How does Linux determine the address of another process to execute with a syscall? Like in this example? mov rax, 59 mov rdi, progName syscall It seems there is a bit of confusion with my question, to clarify, what I was asking is how does syscall works, independently of the

What are the differences between LD_PRELOAD and strace?

自古美人都是妖i 提交于 2020-05-26 04:10:23
问题 Both methods are used to gather system calls also parameters and return values of them. When we prefer LD_PRELOAD and why? Maybe we can say that we can only gather syscalls via strace but we can gather library calls with LD_PRELOAD trick. However, there is another tracer for libraries whose name is ltrace . 回答1: strace is using the ptrace(2) syscall (with PTRACE_SYSCALL probably), so will catch every system call (thru kernel hooks installed by ptrace ). It will work on any executable, even on

What are the differences between LD_PRELOAD and strace?

三世轮回 提交于 2020-05-26 04:08:01
问题 Both methods are used to gather system calls also parameters and return values of them. When we prefer LD_PRELOAD and why? Maybe we can say that we can only gather syscalls via strace but we can gather library calls with LD_PRELOAD trick. However, there is another tracer for libraries whose name is ltrace . 回答1: strace is using the ptrace(2) syscall (with PTRACE_SYSCALL probably), so will catch every system call (thru kernel hooks installed by ptrace ). It will work on any executable, even on

How to directly invoke the system shell in Go (golang)?

我们两清 提交于 2020-05-09 17:28:40
问题 As per the golang documentation, go does not make a call to the system's shell when you are using exec.Command(). From the golang.org documentation on the "os/exec" package: Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. This presents a problem. Because of this design choice you cannot use piping

How to directly invoke the system shell in Go (golang)?

给你一囗甜甜゛ 提交于 2020-05-09 17:27:17
问题 As per the golang documentation, go does not make a call to the system's shell when you are using exec.Command(). From the golang.org documentation on the "os/exec" package: Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells. This presents a problem. Because of this design choice you cannot use piping