Re: Linking Libraries?

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

 



Gre7g Luterman wrote:

On Thu, May 7, 2009 at 10:35 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
You should link with m68k-elf-gcc, not with m68k-elf-ld.

Looks like everything is in libc, so I put that one in.

No! Only the "board-independent" functions are there. The
"board-dependent" aka HW-dependent functions are in their
own "glue libraries". There are some supported boards with
their glue libraries in newlib. For instance the Coldfire
SBC5204 and SBC5206 boards seem to have something like a
"DBUG" monitor firmware and the glue library communicates
with its routines (to the hardware). The related linker
scripts start with something like (sbc5206.ld) :

---------------- clip --------------------------
/* STARTUP(crt0.o) */
OUTPUT_ARCH(m68k)
/* Uncomment this if you want srecords. This is needed for a.out
 * if you plan to use GDB.
OUTPUT_FORMAT(srec)
 */
SEARCH_DIR(.)
GROUP(-ldbug -lc -lgcc)
__DYNAMIC  =  0;

/*
 * Setup the memory map of the Arnewsh SBC5206
 * stack grows down from high memory.
 *
 * The memory map look like this:
---------------- clip --------------------------

The 'libdbug.a' glue library will be used too...  Generally
looking at the existing linker scripts could be useful.

The default 'specs' also defines rules for linking, I would
assume '-lgcc -lc' being automatically used just as well as
linking 'crtbegin.o' and 'crtend.o', these being "generic".
But the linker script should take care of the rest... If you
need the toolchain only for one board, then making a custom
'specs' where the right linker script is mentioned, could be
one choice, for instance :

---------------- clip --------------------------
*endfile:
crtend.o%s -T mcf5275.ld%s

*link:


*lib:


*libgcc:


*startfile:
crtbegin.o%s

---------------- clip --------------------------

The main STARTUP and libraries (GROUP) told in the linker script.

Editing the 'specs' needs being careful, the format really is that
rigid :

<specname>:
<spec itself>
empty line

for each 'spec'...  The default place for the 'specs', the built-in
default got via 'm68k-elf-gcc -dumpspecs > specs', is in your case the :

d:/program files/codesourcery/lib/gcc/m68k-elf/4.3.2

After generating it you can edit it to fir for your own needs...

m68k-elf-gcc.exe -m5200 -I../include -lc -T mcf5275.ld -v cdu.o main.o menuo te
st.o uart.o mcf5xxx.o -o menu.elf

So your own 'mcf5275.ld' script would require some tinkering...

d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x10): undefined reference to `sbrk'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x18): undefined reference to `write'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x10): undefined reference to `close'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x14): undefined reference to `fstat'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x10): undefined reference to `isatty'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x18): undefined reference to `lseek'
d:/program files/codesourcery/bin/../lib/gcc/m68k-elf/4.3.2/../../../../m68k-elf
/lib\libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x18): undefined reference to `read'
collect2: ld returned 1 exit status
make: *** [menu.elf] Error 1

All these, 'sbrk()', 'write()',...,'read', are functions which belong
to that "low-level-I/O" category. If there isn't any standard firmware
with already implemented routines, one must implement them oneself...

The sources for the support glue routines are in 'libgloss/m68k' in the
newlib sources.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux