Hi
i can only compile newlib in .a , how to compile it in .so (shared lib)?
Which option i need to apply for configure?
thanks
from Peter ([email protected])
compile newlib into .so
If you're still having problems with it, I could suggest a way to do it... (just thought of it!)
In a bash script should do it?
Code: Select all
#!/bin/bash
mkdir tmp
cd tmp
ar x ../libc.a
gcc -G --shared -o libc.so <put flags here> *.o
cp libc.so ../
cd ..
rm -Rf tmp
ELF shared libraries are usually position-independent code whereas static libraries are not - they just have their relocations resolved at link time. They are not only linked differently, but compiled differently in that you need to use a different relocation type (e.g. GOT relative or jump via the PLT) and generally the basic code emitted to call/access data through these relocations is different than what is used in static linking. Therefore, you need to also recompile every source file with the -fpic option too. The libtool script is very handy here.
Newlib does not support shared libraries on many targets, simply because it assumes shared library support not to exist on these targets. 'Support' for a shared library requires far more than just a cross compiler that can emit position-independent code and GOT/PLT relative relocations, you also need a dynamic linker, which is part of the operating system, to fixup all the GOT entries.
As the OP is presumably writing their own operating system (as they're posting to this forum) you still need to be able to answer yes to each of the questions I asked previously to get shared libraries to work. Actually, a dynamic linker isn't that hard, provided you read the required reading.
Regards,
John.
Newlib does not support shared libraries on many targets, simply because it assumes shared library support not to exist on these targets. 'Support' for a shared library requires far more than just a cross compiler that can emit position-independent code and GOT/PLT relative relocations, you also need a dynamic linker, which is part of the operating system, to fixup all the GOT entries.
As the OP is presumably writing their own operating system (as they're posting to this forum) you still need to be able to answer yes to each of the questions I asked previously to get shared libraries to work. Actually, a dynamic linker isn't that hard, provided you read the required reading.
Regards,
John.