sparc elf
Jeff Johnston
jjohnstn@redhat.com
Tue Jun 13 00:34:00 GMT 2006
Niklaus wrote:
> Hi,
> I have been trying to build sparc elf executables from i386. I got
> gcc,binutils and newlibc and configured them with target=sparc-elf .
> Now when i got gcc and binutils working , i wrote a small program
>
> test.c:
> int main()
> {
> return 3;
> }
>
> i compiled it using sparc-elf-gcc -c test.c.
> ./sparc-elf-ld --entry=main test.o -o a.out
> when i executed a.out on sparc machine it segfaulted and dumped core.
>
> Why does this happen. This is a very small executable and everything
> is static. Where i am i doing wrong.
>
Niklaus,
The entry point is not main. The entry point typically is _start
which is provided by crt0.o and eventually calls main. I would not
advise linking yourself. Let the compiler do it for you (i.e. don't use
sparc-elf-ld, use sparc-elf-gcc instead). There are a number of ld
scripts in the libgloss/sparc directory. You may have to specify one of
the them explicitly (via the -Txxx.ld option on the compile) if the
compiler doesn't default an appropriate one for you. If your board is
unique, you may have to take one of the closest ld scripts you can find
and modify it.
-- Jeff J.
More information about the Newlib
mailing list