LD Relocation Problem

Pavel Roskin proski@gnu.org
Mon Oct 20 05:32:00 GMT 2003


On Sun, 19 Oct 2003, Kiran Chandrashekaran, Nair (IE10) wrote:

> I am facing the following problem, trying to build a relocatable out put
> linking multiple files, with ld 2.13 for mingw32

I'm trying to do the same.

> This is the ld command that I use.
>
> ld -d -r -nostdlib <more than 5 object files> -o test.exe

"-r" is a wrong option.  It combines object files into another object
files.  It doesn't create a PE file (i.e. Windows executable) - it creates
a COFF file.  "ld -r" can also crash (fixed in CVS).

What you should be looking for is "--emit-relocs" (or "-q"), but it's only
supported for ELF files.  It would be great if we could add relocation
support for the PE format.

RSXNT sources could be used as reference:
http://www.mathematik.uni-bielefeld.de/~rainer/download/rsxntdj16beta2.tar.gz

Conversion from COFF relocs to PE relocs can be found in the file
rsxntdj/source/pe/coff2pe.c, and it's fairly simple.  The hard part would
be to integrate it nicely in binutils.  I wish I could do it, but I'm not
really familiar with binutils to do it fast.

RSXNT and lcc-win32 can create relocatable Windows executables.  lcc-win32
is not free software.

-- 
Regards,
Pavel Roskin



More information about the Binutils mailing list