* HELP - GCC Cross Compiler: LD Returns "`_atexit` undefined in fuction `__do_global_ctors'"
@ 2000-08-04 23:17 Dominic Clifton
2000-08-05 22:18 ` Russ.Shaw
0 siblings, 1 reply; 2+ messages in thread
From: Dominic Clifton @ 2000-08-04 23:17 UTC (permalink / raw)
To: crossgcc
Hi there..
I'm tying to get a cross-compiler working so that I can code C programs for
a Sega Dreamcast (Hitachi SH4).
I downloaded:
binutils-2.10.tar.gz
gcc-core-2.95.2.tar.gz
uncompressed them to /usr/src/crosscompiler and then did the following
commands:
$ target=sh-elf
$ prefix=/usr/local/crosscompiler
$ i=$prefix/bin
$ PATH=$i:$PATH
$ mkdir build-binutils
$ mkdir build-gcc
$ cd build-binutils
$ ../binutils-2.10/configure --target=$target --prefix=$prefix
$ make all install
$ cd ../build-gcc
$
../gcc-2.95.2/configure --target=$target --prefix=$prefix --without-headers
--without-libs --with-cpu=sh4
Then "vi /gcc/Makefile" and adding "-Dinhibit_libc" to
"TARGET_LIBGCC2_CFLAGS="
$ make LANGUAGES="c" all install
Then I add my new /bin directory with my new binaries to the path
$ PATH=$i:$PATH
Then I'm creating a "test.c" file:
void main ( void) {
}
Then I compile like this:
sh-elf-gcc -ml -Wl,-Ttext,0x8c010000 -nostartfiles -nostdlib -e _main
test.c -o test.elf -lgcc
and it returns:
test.c: In function `main':
test.c:1: warning: return type of `main' is not `int'
/usr/local/crosscompiler/lib/gcc-lib/sh-elf/2.95.2/ml/libgcc.a(__main.o): In
fuction `__do_global_ctors':
__main.o(.text+0x74): undefined reference to `atexit'
collect2: ld returned 1 exit status
How do I fix this ?
I'm guessing I need some form of linker script, but can someone tell me what
I need please ?
I've been trying to get this to work for a week now, it's driving me mad!
Dom
p.s. I downloaded "newlib-1.8.2.tar.gz" and "make"'d that, but the same
thing
happens. (Which I'd of expected anyway..)
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: HELP - GCC Cross Compiler: LD Returns "`_atexit` undefined in fuction `__do_global_ctors'"
2000-08-04 23:17 HELP - GCC Cross Compiler: LD Returns "`_atexit` undefined in fuction `__do_global_ctors'" Dominic Clifton
@ 2000-08-05 22:18 ` Russ.Shaw
0 siblings, 0 replies; 2+ messages in thread
From: Russ.Shaw @ 2000-08-05 22:18 UTC (permalink / raw)
To: Dominic Clifton; +Cc: crossgcc
Shouldn't you be logged as root to do the make all install step?
In your compile step:
> sh-elf-gcc -ml -Wl,-Ttext,0x8c010000 -nostartfiles -nostdlib -e _main
-Wl,-Ttext is telling the linker to use the linker script: 'text', iirc.
I don't know what the 0x8c010000 is for.
In this step:
> ../gcc-2.95.2/configure --target=$target --prefix=$prefix --without-headers
> --without-libs --with-cpu=sh4
I wouldn't think --without-libs and --without-headers is necessary, because
i've found that the C libs only get included when you #include the relevant
header files.
In straight C, the crt0.o start-up file calls _main. In C++ iirc, __main and
___main are called to do constructors and destructors, so i think you must
be using a C++ start-up file. Using your own start-up one will probably fix
it.
In /usr/local/crosscompiler/libs, or somewhere around there, you might find
a directory called ldscripts. Looking at these will give clues on how to
write your own.
Dominic Clifton wrote:
>
> Hi there..
>
> I'm tying to get a cross-compiler working so that I can code C programs for
> a Sega Dreamcast (Hitachi SH4).
>
> I downloaded:
>
> binutils-2.10.tar.gz
> gcc-core-2.95.2.tar.gz
>
> uncompressed them to /usr/src/crosscompiler and then did the following
> commands:
>
> $ target=sh-elf
> $ prefix=/usr/local/crosscompiler
> $ i=$prefix/bin
> $ PATH=$i:$PATH
>
> $ mkdir build-binutils
> $ mkdir build-gcc
>
> $ cd build-binutils
> $ ../binutils-2.10/configure --target=$target --prefix=$prefix
> $ make all install
>
> $ cd ../build-gcc
> $
> ../gcc-2.95.2/configure --target=$target --prefix=$prefix --without-headers
> --without-libs --with-cpu=sh4
>
> Then "vi /gcc/Makefile" and adding "-Dinhibit_libc" to
> "TARGET_LIBGCC2_CFLAGS="
>
> $ make LANGUAGES="c" all install
>
> Then I add my new /bin directory with my new binaries to the path
>
> $ PATH=$i:$PATH
>
> Then I'm creating a "test.c" file:
>
> void main ( void) {
> }
>
> Then I compile like this:
>
> sh-elf-gcc -ml -Wl,-Ttext,0x8c010000 -nostartfiles -nostdlib -e _main
> test.c -o test.elf -lgcc
>
> and it returns:
>
> test.c: In function `main':
> test.c:1: warning: return type of `main' is not `int'
> /usr/local/crosscompiler/lib/gcc-lib/sh-elf/2.95.2/ml/libgcc.a(__main.o): In
> fuction `__do_global_ctors':
> __main.o(.text+0x74): undefined reference to `atexit'
> collect2: ld returned 1 exit status
>
> How do I fix this ?
>
> I'm guessing I need some form of linker script, but can someone tell me what
> I need please ?
>
> I've been trying to get this to work for a week now, it's driving me mad!
>
> Dom
>
> p.s. I downloaded "newlib-1.8.2.tar.gz" and "make"'d that, but the same
> thing
> happens. (Which I'd of expected anyway..)
>
> ------
> Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
--
*******************************************
* Russell Shaw, B.Eng, M.Eng(Research) *
* email: russell@webaxs.net *
* Australia *
*******************************************
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-08-05 22:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-04 23:17 HELP - GCC Cross Compiler: LD Returns "`_atexit` undefined in fuction `__do_global_ctors'" Dominic Clifton
2000-08-05 22:18 ` Russ.Shaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).