32-bit absolute address out of range

0

I am newbie to assembly language. Now I am compiling my 'hello,world' .s program.

the code is this from book "Professional Assembly Language" by Richard Blum:

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

.section .data,
output:
    .ascii "The processor vendor is 'xxxxxxxxxx'\n"

.section .bbs,

.section .text,
.globl _main
_main:  
    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 $output, %ecx
    ;; movl $42, %edx
    ;; int $0x80
    ;; movl $1, %eax
    ;; movl $0, %ebx
    ;; int $0x80

the book instructs to compile using 'as' and 'ld', but I failed to use them. then I use gcc: gcc -o cpuid cpuid.s, but still get the error:

****:asm $ls
cpuid.s
****:asm $gcc -o cpuid cpuid.s 
final section layout:
    __TEXT/__text addr=0x100000F58, size=0x0000003C, fileOffset=0x00000F58, type=1
    __TEXT/__stubs addr=0x100000F94, size=0x00000006, fileOffset=0x00000F94, type=27
    __TEXT/__stub_helper addr=0x100000F9C, size=0x0000001A, fileOffset=0x00000F9C, type=31
    __TEXT/__unwind_info addr=0x100000FB6, size=0x00000048, fileOffset=0x00000FB6, type=21
    __DATA/__program_vars addr=0x100001000, size=0x00000028, fileOffset=0x00001000, type=29
    __DATA/__nl_symbol_ptr addr=0x100001028, size=0x00000010, fileOffset=0x00001028, type=28
    __DATA/__la_symbol_ptr addr=0x100001038, size=0x00000008, fileOffset=0x00001038, type=26
    __DATA/__common addr=0x100001040, size=0x00000020, fileOffset=0x00000000, type=24
    .data/ addr=0x100002000, size=0x00000025, fileOffset=0x00002000, type=0
    .text/ addr=0x100003000, size=0x0000003F, fileOffset=0x00003000, type=0
ld: 32-bit absolute address out of range (0x100002000 max is 4GB): from _main + 0x00000028 (0x100003000) to output (0x100002000) in _main from /var/folders/p2/s66vmvlx0vxc7svvwtjfnjb80000gn/T//ccKx07kO.o for architecture x86_64
collect2: ld returned 1 exit status
****:asm $

My environment is: mac os 10.7, 64bit

****:asm $uname -a
Darwin **** 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
****:asm $

Could you help me compile this code?

assembly
asked on Stack Overflow Sep 6, 2013 by wuhaochi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0