繁体   English   中英

在程序集x86中将int更改为syscall / sysenter时出现分段错误(Linux)

[英]Segmentation fault when I change int to syscall/sysenter in assembly x86 (linux)

当我在以下代码中将系统调用从int $0x80更改为syscallsysenter时:

mov $4, %rax
mov $1, %rbx
mov $String1, %rcx
mov $16, %rdx
int $0x80

#where String1 is defined sooner as String1: .asciz "String numero 1\n"

它给了我一个分割错误。 在GDB中,我收到消息

程序收到信号SIGSEGV,分段故障。 0x00000000f7ffdbe9 in ?? ()

由于我根本不是组装专家,所以我不知道发生了什么

编辑 :使用asld构建程序,没有特殊参数

Edit2 :根据lshw | grep syscall的输出,我正在使用x86_64系统lshw | grep syscall lshw | grep syscall返回:

capacidades:X86-64 FPU fpu_exception WP VME德PSE TSC MSR,PAE MCE CX8 APIC月MTRR PGE MCA CMOV拍拍PSE36 CLFLUSH DTS ACPI MMX SSE FXSR SSE2 SS HT TM PBE 系统调用 NX rdtscp constant_tsc arch_perfmon PEBS BTS rep_good nopl xtopology nonstop_tsc aperfmperf PNI dtes64显示器ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm tpr_shadow vnmi flexpriority ept vpid dtherm arat cpufreq

但是它没有返回给sysenter ...

@Jester在评论中说,这种不同的系统调用意味着要为参数加载不同的寄存器。 那是那些寄存器呢? 提前致谢

多亏了评论,解决了问题。

首先,我的体系结构不支持sysenter。 为了进行系统调用,我必须将代码替换为:

mov $1, %rax
mov $1, %rdi
mov $String1, %rsi
mov $16, %rdx
syscall

而且效果很好

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM