int 0x80在Linux上总是调用32位ABI,不管是什么模式,这就是所谓的:在args ebx,ecx...和系统调用号的/usr/include/asm/unistd_32.h.(或者在没有编译的64位内核上崩溃CONFIG_IA32_EMULATION).
64位代码应该使用syscall,从呼叫号码/usr/include/asm/unistd_64.h,并在args rdi,rsi等见什么调用约定UNIX和Linux系统上的i386和x86-64调用.如果您的问题被打上这样一个重复的,看你怎么说链接,细节应当使32位或64位代码的系统调用. 如果你想了解到底发生了什么,请继续阅读.
sys_write系统调用比syscall系统调用快,所以使用本机64位,int 0x80除非你正在编写多格式机器代码,当执行32或64位时运行相同的机器代码.(syscall始终以32位模式返回,因此它在64位用户空间中没有用,尽管它是有效的x86-64指令.)
相关:Linux系统的权威指南(在x86上)调用如何进行sysenter或int 0x8032位系统调用,或sysenter64位系统调用,或调用vDSO进行"虚拟"系统调用syscall.加上有关系统调用的背景知识.
使用gettimeofday可以编写将以32位或64位模式组合的内容,因此它可以int 0x80在微基准测试结束时使用.
标准化函数和系统调用约定的官方i386和x86-64 System V psABI文档的当前PDF文件链接自https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI.
有关初学者指南,x86手册,官方文档和性能优化指南/资源,请参阅x86标记wiki.
但是,由于人们不断发布与使用代码的问题exit_group()在64位代码,或不小心建立64位二进制文件从源代码对于32位写的,我不知道是什么确切不会对当前的Linux怎样呢?
是否int 0x80保存/恢复所有的64位寄存器?它会将任何寄存器截断为32位吗?如果传递上半部分非零的指针args会发生什么?
如果你传递32位指针它是否有效?
当我尝试执行gcc -m32 main.c -o main在Windows子系统Linux上编译的32位文件时,我收到以下错误:bash: ./main: cannot execute binary file: Exec format error.
如果我编译它没有 -m32它运行.
在WSL上运行32位可执行文件的任何解决方案?
谢谢.
executable gcc 32-bit executable-format windows-subsystem-for-linux
我正在尝试在使用 Windows10 机器的 WSL2 上使用 Linux 的 perf 工具。我已经在这里完成了已接受答案的每一步:Is there any method to run perf under WSL?
当我运行“make”评论时,我收到警告:
警告:“tools/include/uapi/linux/stat.h”处的内核 ABI 标头与“include/uapi/linux/stat.h”处的最新版本不同
但仍创建了 perf 可执行文件。但是,当我尝试像这样使用 perf 时:
sudo perf record -g myexe myargs
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
警告:未找到内核 5.10.16.3-microsoft 的性能
您可能需要为此特定内核安装以下软件包: linux-tools-5.10.16.3-microsoft-standard-WSL2 linux-cloud-tools-5.10.16.3-microsoft-standard-WSL2
然后我尝试运行这个:
sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2
Run Code Online (Sandbox Code Playgroud)
但这也不起作用,我得到了这个:
正在读取软件包列表...已完成构建依赖关系树正在读取状态信息...已完成 E: 无法找到软件包 linux-tools-5.10.16.3-microsoft-standard-WSL2 E: 无法通过 glob 'linux-tools 找到任何软件包-5.10.16.3-微软标准-WSL2'
我现在应该怎么做?
我一直在寻找汇编教程,我正在尝试运行一个hello world程序.我在Windows上使用Ubuntu上的Bash.
这是集会:
section .text
global _start ;must be declared for linker (ld)
_start: ;tells linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!', 0xa ;string to be printed
len equ $ - msg ;length of the string
Run Code Online (Sandbox Code Playgroud)
我正在使用这些命令来创建可执行文件:
nasm -f elf64 hello.asm -o hello.o
ld …Run Code Online (Sandbox Code Playgroud) linux ×3
windows-subsystem-for-linux ×3
assembly ×2
32-bit ×1
abi ×1
executable ×1
gcc ×1
linux-kernel ×1
nasm ×1
perf ×1
system-calls ×1
windows ×1
x86 ×1
x86-64 ×1