Re: Error while linking file

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

 



On my i686 machine, I compile personal assembly like
this:

nasm -f elf hello.asm -o hello.o
ld -o hello hello.o

That works for me.  From your problem, I would assume
that GNU ld isn't compatible with aout format, that's
why it doesn't work for you.  Try ELF and see if that
works.
Also, I would encourage use of Nasm; afterall, it is
very compatible when properly used.

--- Jinesh K J <jineshkj.newsletters@xxxxxxxxx> wrote:

> 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/
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--
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