cat /etc/redhat-release看到操作系统是CentOS Linux release 7.6.1810,uname -r看到内核版本是3.10.0-957.el7.x86_64,as --version看到as的版本是2.27-34.base.el7,ld --version看到ld的版本是2.27-34.base.el7。
在这里插入图片描述

absCallWithStart.s里边的代码如下:

.section .data
.global _start
.section .text
_start:
   movq $-5,%rdi
   call abs


   movq %rax,%rdi
   movq $0x3c,%rax
   syscall

这一段代码主要是求-5的绝对值。
as absCallWithStart.s -o absCallWithStart.o进行汇编。
ld absCallWithStart.o -static -lc -o absCallWithStart进行链接,报错ld: cannot find -lc。
在这里插入图片描述

sudo yum install -y glibc-static安装glibc-static。
在这里插入图片描述

ld absCallWithStart.o -static -lc -o absCallWithStart再次进行链接,./absCallWithStart进行执行,echo $?查看一下返回值。
在这里插入图片描述

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐