【发布时间】:2015-08-05 20:14:39
【问题描述】:
这里是cpuid2.s的代码:
#cpuid2.s view the cpuid vendor id string using c library calls
.section .data
output:
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12
.section .text
.global _start
_start:
movl $0, %eax
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
push $buffer
push $output
call printf
addl $8, %esp
push $0
call exit
我是这样组装、链接和运行它的:
as -o cpuid2.o cpuid2.s
ld -dynamic-linker /lib/ld-linux.so.2 -o cpuid2 -lc cpuid2.o
./cpuid2
bash: ./cpuid2: Accessing a corrupted shared library
我已经在 StackOverflow 上搜索过这个错误。我发现this question 与我的相似。我尝试了@rasion 给出的方法。像这样:
as -32 -o cpuid2.o cpuid2.s
ld -melf_i386 -L/lib -lc -o cpuid2 cpuid2.o
ld: cannot find -lc
他的回答并没有解决我的问题。我希望有人可以帮助我。
我在 GNU 汇编器中使用 AT&T 语法。
我的电脑有 64 位 Ubuntu 14.04。
【问题讨论】:
标签: assembly x86 32bit-64bit