Page 1 of 1

FAQ : linkers

Posted: Fri Feb 13, 2004 3:50 am
by Pype.Clicker
here comes a question from http://www.osdev.org/osfaq2/index.php/Linkers
Is it still true ld can't create shared libraries, or is this dated information?
As far as i know, ld does not create shared libraries by itself. You have to give the proper flags to GCC itself so that it can generate position-independent code (note that i'm only talking about ELF shared libraries).

What i know for sure is that LD is able to link while keeping relocations in your final object (called the 'incremental link') and it also can stand unresolved symbols if instructed to do so ...

Re:FAQ : linkers

Posted: Sat Feb 14, 2004 4:23 am
by Tim
On the PE side, you have to use a huge hack to get LD to generate relocatable DLLs. This involves running LD three (!) times:

Code: Select all

   ld -s --base-file $(BASE).base --dll -o $(TARGET) $(OBJS) $(LIBS) $(LDFLAGS)
   dlltool --as=as --dllname $(TARGET) $(DTFLAGS) --base-file $(BASE).base --output-exp $(EXP_TEMP)
   ld -s --base-file $(BASE).base --dll -o $(TARGET) $(OBJS) $(LIBS) $(LDFLAGS)
   dlltool --as=as --dllname $(TARGET) $(DTFLAGS) --base-file $(BASE).base --output-exp $(EXP_TEMP)
   ld --dll -o $(TARGET) $(EXP) $(OBJS) $(LIBS) $(LDFLAGS)