You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何在汇编代码中调用strlen会触发段错误?

段错误问题:strlen调用导致程序崩溃

尝试向localhost发起请求并获取消息长度时,程序触发段错误,具体信息如下:

程序输出

helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS  helloS./run.sh: line 1: 10066 Segmentation fault: 11

lldb调试信息

lldb调试信息

代码对比

原代码中使用以下汇编指令获取消息长度时出现崩溃:

adr x0, _msg
bl _strlen

将上述代码替换为直接赋值后,程序可正常运行:

mov x0, #5

内容的提问来源于stack exchange,提问作者Den Avrondo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 00:43:11