GAS AT&T linkage issue

Colin Barnabas colin.barnabas at gmail.com
Wed Jul 4 23:30:50 UTC 2012


I've been dabbling in assembly and decided to try AT&T syntax and
the GAS assembler. I'm trying to get a cpuid test program
running. It assembles fine if I give the command: 

as -o cpuid.o cpuid.s 

But starts complaining when I try to link it with:

ld -o cpuid cpuid.o

Which produces these errors:

cpuid.o: In function `_start':
(.text+0x10): undefined reference to `ebx'
cpuid.o: In function `_start':
(.text+0x18): undefined reference to `edx'
cpuid.o: In function `_start':
(.text+0x20): undefined reference to `ecx'

Im running FreeBSD 9.0-RELEASE amd64 and here is the text I am
using:

#cpuid.s Sample  program to extract the processor Vendor ID

.section .data
output:
        .ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"

.section .text
.globl _start
_start:
        movl $0, %eax
        cpuid
        movl $output, %edi
        movl $ebx, 28(%edi)
        movl $edx, 32(%edi)
        movl $ecx, 36(%edi)
        movl $4, %eax
        movl $1, %ebx
        movl $output, %ecx
        movl $42, %edx
        int $0x80
        movl $1, %eax
        movl $0, %ebx
        int $0x80

Any advice would be appreciated.

-- 
Colin Barnabas


More information about the freebsd-hackers mailing list