学习汇编知识,在连接的时候出问题
#cpuid2.s View the CPUID Vendor ID string using C library calls
.code32
.section .data
output:
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer,12
.section .text
.globl _start
_start:
movl $0, %edi
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
pushl $buffer
pushl $output
call printf
addl $8, %esp
pushl $0
call exit
gcc version 9.3.0,Ubuntu20.0版64位
动态加载器是ld-linux-x86-64.so.2
按照书上的描述
实际操作
gewei@ubuntu:~/C语言$ as -o cpuid2.o cpuid2.s
gewei@ubuntu:~/C语言$ ld -dynamic-linker /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -o cpuid2 -L/usr/lib/x86_64-linux-gnu -lc cpuid2.o
gewei@ubuntu:~/C语言$ ./cpuid2
段错误 (核心已转储)
此处也用ulimit -s 设置stack size
求大神帮忙分析下,该怎么用GNU连接器才能连接出结果。