Linkers

Programming, for all ages and all languages.
Post Reply
Therx

Linkers

Post 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
Tim

Re:Linkers

Post by Tim »

You should use LD as a linker if you're using AR and GCC.
Therx

Re:Linkers

Post 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
Tim

Re:Linkers

Post 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.
Therx

Re:Linkers

Post 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
Tim

Re:Linkers

Post 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.
Therx

Re:Linkers

Post by Therx »

Do all versions of GCC use djgpp coff rather than Win32 COFF
Tim

Re:Linkers

Post by Tim »

Like I say, all the versions I've seen support 'regular' COFF. Cygwin also supports Win32-COFF, which is slightly different.
Post Reply