avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] Suggestion for FAQ entry - LD vs. GCC


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] Suggestion for FAQ entry - LD vs. GCC
Date: Tue, 29 Mar 2005 23:36:15 +0200
User-agent: Mutt/1.4.2.1i

As Onno Kortmann wrote:

> If one tries to build an AVR program the usual linux way:
> 
> $ avr-gcc -c hello-world.c 
> $ avr-ld -o hello-world.elf hello-world.o

I don't mind the FAQ entry for it, but be warned: this is equally
wrong under any kind of Unix as well.  The official frontend to link
your job is the standard compiler driver for your language (cc, or
c++), *not* ld directly.  If you call ld directly, you're supposed to
know what you're doing.  (E.g. in some C++ compilers, you might miss
to include the code for global constructors/destructors, perhaps even
without getting any kind of warning.)

Just out of curiosity, I tried it on the native compiler in my FreeBSD
box, and it fails in similar ways:

% cat > foo.c
#include <stdio.h>
int main(void) { printf("Hello world!\n"); return 0; }
^D
% cc -c foo.c
% ld foo.o
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
foo.o(.text+0x25): In function `main':
: undefined reference to `printf'
% ld foo.o -lc
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048204
/usr/lib/libc.so: undefined reference to `environ'
/usr/lib/libc.so: undefined reference to `__progname'

If this works on Linux, it is merely incidentally than anything you
could/should rely on.


If other people agree it's worth a FAQ entry, I'll include it though.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]