bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

binutils 2.11: another ARM relocation problem in linker (3)


From: Eberhard Mattes
Subject: binutils 2.11: another ARM relocation problem in linker (3)
Date: Tue, 21 Aug 2001 17:22:46 +0200

Scratch part (2) of this story, it was a red herring (the ABS
relocation was just used for padding).

First, let me repeat my problem (the target is arm-epoc-pe): I got
missing and wrong relocations when creating a DLL which exports a
symbol imported from another DLL but otherwise not used.

The cause of the problem is that ld needs to be run twice, first to
create a base file, then to create the DLL.  In between, dlltool is
used to create an export file, which will be used by the second run of
ld.  That export file adds an import which was not present in the
first run of ld (as the imported symbol is only exported, so was not
visible to ld in the first run).  Therefore, in the second pass, the
sections contain more data and there are more symbols, but the export
file still contains the relocations of the first pass, resulting in
missing relocations and relocations for incorrect locations.

The solution is to create another base file in the second run of ld;
if that base file differs from the one created in the first pass,
dlltool needs to be run again to create a new export file (including
the relocations for the imports requested by the first export file),
then ld needs to be run again to use that new export file.  In sh:

----------------------------------------------------------------------
arm-epoc-pe-dlltool --output-lib imp.a --input-def imp.def --dllname imp
arm-epoc-pe-as -o main.o main.s
arm-epoc-pe-ld -v --dll -e entry --base-file tmp.bas -o tmp.pex main.o imp.a
arm-epoc-pe-dlltool --output-lib tmp.lib --input-def main.def \
        --dllname main --base-file tmp.bas --output-exp tmp.exp
arm-epoc-pe-ld -v --dll -e entry --base-file tmp.bas2 -o tmp.pex tmp.exp main.o 
imp.a

if ! cmp -s tmp.bas tmp.bas2
then
  arm-epoc-pe-dlltool --output-lib tmp.lib --input-def main.def \
        --dllname main --base-file tmp.bas2 --output-exp tmp.exp2
  arm-epoc-pe-ld -v --dll -e entry --base-file tmp.bas3 -o tmp.pex tmp.exp2 
main.o imp.a
  if ! cmp tmp.bas2 tmp.bas3
  then
    echo oops
    exit 1
  fi
fi
----------------------------------------------------------------------

This is a mess.  Apparently, ld includes code to create DLLs directly:
does DLL_SUPPORT of ld (pe-dll.c) work?  DLL_SUPPORT is not set
anywhere...

Eberhard Mattes



reply via email to

[Prev in Thread] Current Thread [Next in Thread]