Re: Error while linking file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/8/06, Manjunath Naik <peter.desouzain@xxxxxxxxx> wrote:
Hi all,

  I was just tring the simple "hello world" assembly program in linux.
First time I was able to compile and link the file.
  I just changed something in that file, I got the following error while
linking it.

   test.o: file not recognized: File format not recognized

  I am not able tounderstand what is the exact problem with it.

  I had used the following two commands to compile nad link the progam.

   nasm -f aout test.asm
   ld -e _start -o test test.o

   my program looks as follows

 section .text
   global _start                       ;must be declared for linker (ld)

_start:                                 ;tell linker entry point

       mov     edx,len ;message length
       mov     ecx,msg ;message to write
       mov     ebx,1   ;file descriptor (stdout)
       mov     eax,4   ;system call number (sys_write)
       int     0x80    ;call kernel

       mov     eax,1   ;system call number (sys_exit)
       int     0x80    ;call kernel

section .data

msg     db      'Hello, world!',0xa     ;our dear string
len     equ     $ - msg                 ;length of our dear string

what might be the problem here?

Regards
Manjunath

I don't really know what the problem is. But, why are you using nasm.
You can use gnu as for the same. Also, this is not the ML for posting
such queries.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux