Porting NewLib to my OS: some questions

I am trying to port NewLib for my OS (I follow this guide: http://wiki.osdev.org/Porting_Newlib ) and I have some questions.

  • After completing and compiling LibGloss, when exactly should I use the created libnosys.a? Is this when I compile my main.c?

    mipsel-uknown-elf-gcc main.c -Llibnosys.a` 
  • My crt0.c is finished. And I need to "bind it as the first object." How can i do this? Is it something like this?

     mipsel-uknown-elf-ld crt0.o main.o 

Thank you for your responses!

+7
c gcc ld newlib
source share
1 answer

Binding as the first object may work as good as you show, but the docs mention using the script linker and adding crt0.o as STARTUP () - I'm not very familiar with linker scripts, but you can find the linker by default script and possibly create it / configure:

Link syntax script: http://wiki.osdev.org/Linker_Scripts

http://sourceware.org/binutils/docs-2.19/ld/Scripts.html#Scripts

 The linker always uses a linker script. If you do not supply one yourself, the linker will use a default script that is compiled into the linker executable. You can use the `--verbose' command line option to display the default linker script. Certain command line options, such as `-r' or `-N', will affect the default linker script. 

The same can be done with other system libraries, which should always be part of the binding.

It's great to add everything on the command line, but a little tedious at the end.

Do you get any errors or incorrect results as you ask or what?

+1
source share

All Articles