Mess with library

"Bob Brusa" <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers.coldfire
Organization private
Message-ID <op.t5fzc5sv8qukij@localhost>
Hi,
I am using the toolchain uClinux (m68k-uclinux-tools-20061214.sh) on a  
Debian (etch) host. The Target is a COBRA5282-Board which operates under  
dBUG. The Board came with an example that blinks with the LEDs on the  
board. The program links with its own target-specific startfile crt0_ram  
and no libraries. It compiles, links and I can download (using NFS) and  
execute it. So far so good. Then I wanted to create another example - a  
simple HelloWorld-Programm. But I get an error. The output is shown below:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rwb@debi28:~/wso/helloworld$ make
/usr/local/bin/m68k-elf-gcc -Wa,-as -m5307 -c crt0_ram.S
68K GAS  /tmp/ccrsskya.s                        page 1


DEFINED SYMBOLS
                             *ABS*:00000000 crt0_ram.S
           crt0_ram.S:39     .text:00000000 _start

UNDEFINED SYMBOLS
main
/usr/local/bin/m68k-elf-gcc -g -m5307 -nostartfiles -c main.c
/usr/local/bin/m68k-elf-ld -T COBRA5282-ram.ld -M -o helloworld.elf  
crt0_ram.o main.o > helloworld.map
main.o: In function `main':
/home/rwb/wso/helloworld/main.c:5: undefined reference to `puts'
make: *** [helloworld.elf] Fehler 1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
It seems, something is wrong with the standard library. Who can help? So  
far I have found nothing that explains the linking process in some  
details. Yes, I have the ld-doc, but it does not explain the basics (which  
I am sorry to say - I do not know yet).

Regards Bob

The source (main.c) is shown below:
-----------------------------------------------
#include <stdio.h>

int main(void)
{
	printf("Hello World\n");
	return 0;
}
------------------------------------------------
The makefile, adapted from the led-example - is:
------------------------------------------------

GCC_EXEC_PREFIX = /usr/local/bin/m68k-elf-

CC = $(GCC_EXEC_PREFIX)gcc
AS = $(GCC_EXEC_PREFIX)as
LD = $(GCC_EXEC_PREFIX)ld
AR = $(GCC_EXEC_PREFIX)ar
OBJCOPY = $(GCC_EXEC_PREFIX)objcopy

PROGNAME = helloworld

TARGET = $(PROGNAME).s19
OBJS = crt0_ram.o main.o

CFLAGS += -g -m5307
# -g produces debugging options (native format)
# -m5307 selects the processor. this options is also ok for the MCF5282.
# the -as option for the assembler is nowhere documented
ASFLAGS += -Wa,-as -m5307

$(PROGNAME).s19: $(PROGNAME).bin
# objcopy converts the binary file to the srec format - .bin to .s19
	$(OBJCOPY) --input-target=binary --output-target=srec $(PROGNAME).bin  
$(PROGNAME).s19
# and the .s19-file is copied to our network-folder
	cp ${PROGNAME}.s19 /tftpboot

$(PROGNAME).bin: $(PROGNAME).elf
# create a binary file using the standard .elf-file as input
	$(OBJCOPY) -O binary $(PROGNAME).elf $@
# and copy the .bin-file to our network-folder
	cp ${PROGNAME}.bin /tftpboot

$(PROGNAME).elf: $(OBJS)
# Link the o-files into memory as specified in the .ld-file  
(linker-script-file)
	$(LD) -T COBRA5282-ram.ld -M -o $(PROGNAME).elf $(OBJS) > $(PROGNAME).map

.S.o:
	$(CC) $(ASFLAGS) -c $<
.c.o:
	$(CC) $(CFLAGS) -nostartfiles -c $<
#compile c-files, but no linking
crt0_ram.o: crt0_ram.S	

all:	$(TARGET)

clean:
	rm $(PROGNAME) *.o *.bin *.s19 *.map *.elf *.gdb -f

------------------------------------------------------------------
and the loader script (COBRA5282-ram.ld) is:
------------------------------------------------------------------

MEMORY {
      ram    : ORIGIN = 0x10000, LENGTH = 0x3e0000
}

SECTIONS {

         .text : {
		_stext = . ;
         	*(.text)
		_etext = ALIGN(0x4) ;
         } > ram

         .data BLOCK(0x4) : {
		_sdata = . ;
		__data_start = . ;
		*(.rodata)
         	*(.data)
		_edata = ALIGN(0x4) ;
         } > ram

         .bss BLOCK(0x4) : {
		_sbss = . ;
		*(.bss)
		*(COMMON)
		_ebss = ALIGN(0x4) ;
		_end = ALIGN(0x4) ;
	} > ram
     __main = main;

}
-------------------------------------------------------------

-- 
Bob Brusa                [email protected]
Chapfwiesenstr. 14       ph: +4144 926 74 74
CH-8712 Stäfa            fx:   +4144 926 73 34
---
[email protected]              Send a post to the list.
[email protected]        Join the list.
[email protected]    Join the list in digest mode.
[email protected]     Leave the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.