PDA

View Full Version : newlib / kos 1.3 / cygwin troubles



Azuki
January 22nd, 2006, 15:12
Well i have downloaded the DC dev Iso R2, after setup and configuration, i write a little prog to test the gcc compilation :

#include <kos.h>
extern uint8 romdisk[];
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
KOS_INIT_FLAGS(INIT_DEFAULT|INIT_MALLOCSTATS);
KOS_INIT_ROMDISK(romdisk);
int main(int argc, char *argv[])
{
return 0;
}

I use two command line to obtain the object and the the elf


1)

sh-elf-gcc.exe -c /test_de_sdl/Test_sdl.c -o /test_de_sdl/Test_sdl.o -I"/usr/local/dc/kos/kos-ports/include" -I"/usr/local/dc/kos/kos/include" -I"/usr/local/dc/kos/kos/kernel/arch/dreamcast/include" -I"/usr/local/dc/kos/kos/addons/include" -I"/usr/local/dc/kos/kos-ports/SDL129/include" -Wall -g -ml -mbigtable -m4-single-only -O3 -nostartfiles -nodefaultlibs -nostdlib -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-optimize-sibling-calls -D_arch_dreamcast

2)

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only" -L"/usr/local/dc/kos/kos/lib/dreamcast" -L"/usr/local/dc/kos/kos/addons/lib/dreamcast" -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/romdisk.o /test_de_sdl/startup.o -lSDL_129 -lkallisti -lgcc -lc
the first command run smoothly and i obtain the test_sdl.o

but the second command produice errors :eek: :


/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(stdio.o)(.text+0xf8):In function `__swrite':../../../../../../../newlib-1.12.0/newlib/libc/stdio/stdio.c:91: undefined reference to `__write_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(stdio.o)(.text+0xfc):../../../../../../../newlib-1.12.0/newlib-
/libc/stdio/stdio.c:91: undefined reference to `__lseek_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(stdio.o)(.text+0x158): In function `__sseek'../../../../../../../newlib-1.12.0/newlib/libc/stdio/stdio.c:111: undefined reference to `__lseek_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(stdio.o)(.text+0x17c): In function `__sclose':../../../../../../../newlib-1.12.0/newlib/libc/stdio/stdio.c:120: undefined reference to `__close_r'

/usr/local/dc/shelf/sh-elf/lib/ml/m4-single-only/libc.a(strdup_r.o)(.text+0x48): In function `_strdup_r':../../../../../../../newlib-1.12.0/newlib/libc/string/strdup_r.c:17: udefined reference to `__malloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(syssbrk.o)(.text+0x18): In function `sbrk':../../../../../../../newli
-1.12.0/newlib/libc/syscalls/syssbrk.c:18: undefined reference to `__sbrk_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(time.o)(.text+0x4c): In function `time':../../../../../../../newlib-1.12.0/newlib/libc/time/time.c:57: undfined reference to `__gettimeofday_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(tzset_r.o)(.text+0x2b8): In function `_tzset_r':../../../../../..
../newlib-1.12.0/newlib/libc/time/tzset_r.c:192: undefined reference to `__malloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(vfprintf.o)(.text+xd38): In function `_vfprintf_r':../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfprintf.c:748: undefined reference to `__malloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(vfprintf.o)(.text+0x154c):../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfprintf.c:1172: undefined reference to `___umddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(wsetup.o)(.text+0110): In function `__swsetup':../../../../../../../newlib-1.12.0/newlib/libc/stdio/wsetup.c:55: undefined reference to `__free_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(fvwrite.o)(.text+0x398): In function `__sfvwrite':../
./../../../../../newlib-1.12.0/newlib/libc/stdio/fvwrite.c:136: undefined refernce to `__realloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(mpec.o)(.text+0xa8): In function `_Balloc':../../../../../../../newlib-12.0/newib/libc/stdlib/mprec.c:125: undefined reference to `__calloc_r'

/usr/local/dc/sh/elf/sh-elf/lib/ml/m4-single-only/libc.a(vfscanf.o)(.text+0x12e4): In function `_svfscanf_r':../../../../../../../newlib-1.12.0/newlib/libc/stdio/vfscanf.c:112
: undefined reference to `___extendsfdf2'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(strtoll_r.o)(.text+0x28c): In function `_strtoll_r':../../../
./../../../newlib-1.12.0/newlib/libc/stdlib/strtoll_r.c:122: undefined reference to `___umoddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(strtoul_r.o)(.text+0x22c): In function `_strtoull_r':../../../../../../../newlib-1.12.0/newlib/libc/stdlib/strtoull_r.c:102: undefined reference to `___umoddi3'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(ungetc.o)(.text+0xac): In fuction `__submore':../../../../../../../newlib-1.12.0/newlib/libc/stdio/ungetc.c:66: undefined reference to `__realloc_r'

/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only/libc.a(ungetc.o)(.text+0xb8):../../../../../../../newlib-1.12.0/newli/libc/stdio/ungetc.c:66: undefined reference to `__malloc_r'

collect2: ld returnd 1 exit status

I try to find out what those reference means and it seems that realloc_r / free_r /malloc_r/calloc_r/ are the reentrant versions of the malloc functions, open_r, close_r, write_r, and read_r,lseek_r functions handle device initialization and shutdown, and data movement to and from the physical device.

All those reference claimed undefined by Gcc are localized in the embedded gnu (newlib) : see here : http://www.embedded.com/story/OEG20020103S0073 .

In the malloc.h (in my kos ) there's reference only to the traditional C function (malloc / realloc/ ...).

The libc.a i use to link is from "/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only" directory. When i see the errors i suspect libc.a to be the problem, if it's the case what should i do ?

So at this point i have no idea what is wrong with this DC env.

somebody help !

thanks

Azuki
January 23rd, 2006, 21:45
Solved !

bigral
January 24th, 2006, 22:41
Solved !

So what did you done?

Azuki
January 25th, 2006, 20:48
i replace this :

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"/usr/local/dc/sh-elf/sh-elf/lib/ml/m4-single-only" -L"/usr/local/dc/kos/kos/lib/dreamcast" -L"/usr/local/dc/kos/kos/addons/lib/dreamcast" -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/romdisk.o /test_de_sdl/startup.o -lSDL_129 -lkallisti -lgcc -lc


to this :

sh-elf-gcc.exe /test_de_sdl/Test_sdl.o -o "test.elf" -L"F:\cygwin\usr\local\dc\sh-elf\sh-elf\lib\ml\m4-single-only" -L"F:/cygwin/usr/local/dc/kos/kos/lib/dreamcast" -L"F:/cygwin/usr/local/dc/kos/kos/addons/lib/dreamcast" -ml -m4-single-only -nostartfiles -nostdlib -nodefaultlibs -Wl,-Ttext=0x8c010000 /test_de_sdl/romdisk.o /test_de_sdl/startup.o -Wl,--start-group -lSDL_129 -lkallisti -lc -lgcc -Wl,--end-group

and it works perfectly :)