Hi,
I have went through building newlib for my OS and followed the below tutorials from OSDev:
https://wiki.osdev.org/OS_Specific_Toolchain (OS Specific Toolchain)
https://wiki.osdev.org/Hosted_GCC_Cross-Compiler (Hosted Cross Compiler)
https://wiki.osdev.org/Porting_Newlib (Porting Newlib)
https://wiki.osdev.org/C_Library (C Library)
I was able to compile and generate executables for my OS against libc.a.
Now I would like to use the shared library approach (libc.so) to be able to load libc once and map it to different processes page tables.
I have searched the internet and OSDev for that but I was not able to find enough information to do that.
Please, if any one was able to do it or has any pointers or directions to documentation for that, I would appreciate sharing such information.
Thanks a lot,
Karim.
How to compile newlib as a shared library (.so) ?
Re: How to compile newlib as a shared library (.so) ?
The only way that I managed this was to do my own linking, having compiled with the -PIC option. It was not easy, and not perfect, so in the end I decided to write my own C library.
Re: How to compile newlib as a shared library (.so) ?
I battled with the newlib build system for a fair while attempting this, before giving up and replacing it with a "simple" Makefile that achieves it. It's not all that difficult... I removed all the files dedicated to supporting other OSs and architectures.
Unfortunately, the "GNU" standard of using autotools/libtool for build systems is rediculously version-sensitive. If you need to make any changes to the build process and you don't have the exact same versions of tools that the original developer had, you're in a world of pain. It also doesn't help that Newlib's build (unless it's been changed very recently) depends on functionality that's been removed in newer versions of autotools ("Cygus trees"; Cygnus being the original developer of Newlib...).
You can see my Makefile here: https://github.com/mallardtheduck/osdev ... c/Makefile
And a similar one for the math library: https://github.com/mallardtheduck/osdev ... c/Makefile
(Obviously you'll need a fair amount of customisation for these to even think about working on another OS, but it mught be a helpful starting point...)
Unfortunately, the "GNU" standard of using autotools/libtool for build systems is rediculously version-sensitive. If you need to make any changes to the build process and you don't have the exact same versions of tools that the original developer had, you're in a world of pain. It also doesn't help that Newlib's build (unless it's been changed very recently) depends on functionality that's been removed in newer versions of autotools ("Cygus trees"; Cygnus being the original developer of Newlib...).
You can see my Makefile here: https://github.com/mallardtheduck/osdev ... c/Makefile
And a similar one for the math library: https://github.com/mallardtheduck/osdev ... c/Makefile
(Obviously you'll need a fair amount of customisation for these to even think about working on another OS, but it mught be a helpful starting point...)
Re: How to compile newlib as a shared library (.so) ?
Thanks a lot,
Will try them out.
Karim.
Will try them out.
Karim.