Page 1 of 1
Linkers
Posted: Sun Feb 01, 2004 10:19 am
by Therx
Following an idea that cam in the os dev forum I'd like to experiment with linking at runtime in a smaller stub. I've googled and searched Sourceforge for small linkers and can't find one that supports the output formats of AR and GCC.
I'm willing to try to write my own if anyone could give me some pointers.
Cheers
Pete
Re:Linkers
Posted: Sun Feb 01, 2004 11:06 am
by Tim
You should use LD as a linker if you're using AR and GCC.
Re:Linkers
Posted: Sun Feb 01, 2004 11:30 am
by Therx
No the idea is that the boot loader loads the object files in at boot and links them giving the output to a memory location which is then jumped to. As my OS is for servers this would speed up time taken to update the kernel. Just replace one object file and reboot. It could also be used for drivers etc. as well.
Pete
PS I posted here because I'm mainly concerned about the general linking process. Which I will first test under Windows
Re:Linkers
Posted: Sun Feb 01, 2004 2:01 pm
by Tim
Ah, so you want to use dynamic linking? Well, you should link as normal to PE or ELF, and set the 'shared library' option. Then your loader needs to know how to parse the import table/symbol table and resolve references to external symbols.
A copy of the relevant file format spec should be all you need.
Re:Linkers
Posted: Sun Feb 01, 2004 2:48 pm
by Therx
I've found info on Chris Geise's site with example code which explains a lot. But I can see a lot of work ahead if I have to support more than one object file type. Is there one 'universal' format amongst gcc.
ELF doesn't work with Cygwin
COFF is different for DJGPP
etc.
Pete
Re:Linkers
Posted: Sun Feb 01, 2004 4:42 pm
by Tim
ELF works on Cygwin if you link to PE then use objcopy to convert to ELF.
All the versions I've seen have COFF in common, even DJGPP and Cygwin.
Re:Linkers
Posted: Sun Feb 01, 2004 4:58 pm
by Therx
Do all versions of GCC use djgpp coff rather than Win32 COFF
Re:Linkers
Posted: Mon Feb 02, 2004 2:05 pm
by Tim
Like I say, all the versions I've seen support 'regular' COFF. Cygwin also supports Win32-COFF, which is slightly different.