I've compiled cpuid2.s to cpuid2.o by as cpuid2.s -o cpuid2.o -gstabs
Firstly I linked it by ld -o cpuid2 cpuid2.o -lc but
a message says ./cpuid2:no such file or directory when I executed it
(which is due to having not use dynamic linker, says the book)
So I linked it by ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cpuid2 cpuid2.o -lc
then executed it, however a SegmentationFault occurs:
when gdb it step by step, gdb says printf.c:no such file or directory at the line call printf
is it because I haven't install C's library(however I can run simple C programs with function in stdio.h)?
#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, %eax
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
printfis very likely correct.%.12sto print no more than 12 characters.