gpt4 book ai didi

assembly 分割错误

转载 作者:行者123 更新时间:2023-12-04 18:54:00 26 4
gpt4 key购买 nike

在运行以下汇编代码时遇到错误

#cpuid using C library Functions
.section .data
output:
.asciz "The Processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12
.section .text
.globl main
main:
movq $0, %rax
cpuid
movq $buffer, %rdi
movq %rbx, (%rdi)
movq %rdx, (%rdi)
movq %rcx, (%rdi)
pushq $buffer
pushq $output
call printf
addq $8, %rsp
pushq $0
call exit

它在C库的部分遇到段错误调用:调用printf
它以x86_64模式运行。
关于C库,我在编译x64代码期间错过了什么吗?还是代码有问题

谢谢

最佳答案

是否调用了C运行时库的初始化?必须首先运行该命令才能设置stdout。顺便说一句,堆栈跟踪将消除对问题原因的怀疑。

另外,请防止%s转换使%.12s溢出缓冲区,或者仅将NUL字节放在缓冲区之后。

关于 assembly 分割错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1817795/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com