This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: dll create problem with gcc configured with arm-pe
- From: "longchuan" <longchuan at koretide dot com dot cn>
- To: "'Nick Clifton'" <nickc at redhat dot com>
- Cc: <binutils at sources dot redhat dot com>, "'Craig A. Vanderborgh'" <craigv at voxware dot com>
- Date: Wed, 16 Apr 2003 15:43:09 +0800
- Subject: RE: dll create problem with gcc configured with arm-pe
Hi Nick and all fellows :
I think this patch is not enough to create dll with relocation. gcc is
configured as ARM-WINCE-PE.
when i debug this dll, and found that the export table was overridden by
relocation fixup.
with objdump -x counter.dll, it show that:
.....
Entry 0 00006000 00001902 Export Directory [.edata (or where ever we
found it)]
....
There is an export table in .edata at 0x10006000
The Export Tables (interpreted .edata section contents)
Export Flags 0
Time/Date stamp 3e9cf9b3
Major/Minor 0/0
Name 00006028 counter.dll
Ordinal Base 1
Number in:
Export Address Table 00000004
[Name Pointer/Ordinal] Table 00000004
Table Addresses
Export Address Table 00006040
.......
Virtual Address: 00006000 Chunk size 32 (0x20) Number of fixups 12
reloc 0 offset c [600c] HIGHLOW
reloc 1 offset 1c [601c] HIGHLOW
reloc 2 offset 20 [6020] HIGHLOW
reloc 3 offset 24 [6024] HIGHLOW
reloc 4 offset 40 [6040] HIGHLOW
reloc 5 offset 44 [6044] HIGHLOW
......
So, address 0x10006040 is corrupted, that is address of export table.
I am sorry i don't have much knowledge about dll relocation, but i
compare with mingw32 for win32 gcc, compiling
the same program, and the result is:
...........
Entry 0 00005000 0000196c Export Directory [.edata (or where ever we
found it)]
............
The Export Tables (interpreted .edata section contents)
Export Flags 0
Time/Date stamp 3e9ba05b
Major/Minor 0/0
Name 00005028 counter.dll
Ordinal Base 1
Number in:
Export Address Table 00000004
[Name Pointer/Ordinal] Table 00000004
Table Addresses
Export Address Table 00005034
.....
no relocation information point to export table address, I think that is
the different.
did I make myself clear? what do you think about this?
regards,
wreckor
> -----Original Message-----
> From: nickc at workshop dot nickc dot cambridge dot redhat dot com
> [mailto:nickc at workshop dot nickc dot cambridge dot redhat dot com] On Behalf
> Of Nick Clifton
> Sent: Tuesday, April 01, 2003 00:05
> To: longchuan
> Cc: binutils at sources dot redhat dot com
> Subject: Re: dll create problem with gcc configured with arm-pe
>
>
> Hi Wreckor,
>
> > ld failed with message:
> > Cannot export TestFunc: symbol not defined
> > test.exp(.edata+0x40): undefined reference to `TestFunc'
>
> As you have already noted, the first thing you need to change
> is the exports in your test.def file, prefixing an underscore
> to TestFunc,
> ie:
>
> LIBRARY test.dll
> EXPORTS
> _TestFunc
>
> This takes care of the second error message.
>
> > I add a leading underscore to def file i.e from TestFunc to
> _TestFunc
> > in test.def and in ld option, i omit -shared option, this
> time i could
> > get the dll file but i don't think this one is what i
> expected. This
> > dll don't have relocation table.
>
> Well without the -shared option the relocations are
> discarded, so the linker is operating correctly. (This is
> because in a non-shared executable, all of the relocations
> should have been resolved, so there is no need for the
> relocation table).
>
> The real problem however is a bug in the linker. Try
> applying the patch below and then rerunning LD, but this
> time, include the -shared command line option.
>
> If this fixes your problem, please let me know so that the
> patch can be applied to the sources.
>
> Cheers
> Nick
>
> ld/ChangeLog
> 2003-03-31 Nick Clifton <nickc at redhat dot com>
>
> * pe-dll.c (pe_detail_list): The pe-arm target does use
> underscores.
>
> Index: ld/pe-dll.c
> ===================================================================
> RCS file: /cvs/src/src/ld/pe-dll.c,v
> retrieving revision 1.55
> diff -c -3 -p -w -r1.55 pe-dll.c
> *** ld/pe-dll.c 21 Feb 2003 10:51:24 -0000 1.55
> --- ld/pe-dll.c 31 Mar 2003 15:59:31 -0000
> *************** static pe_details_type pe_detail_list[]
> *** 199,205 ****
> 11 /* ARM_RVA32 */,
> PE_ARCH_arm,
> bfd_arch_arm,
> ! 0
> },
> {
> "epoc-pei-arm-little",
> --- 199,205 ----
> 11 /* ARM_RVA32 */,
> PE_ARCH_arm,
> bfd_arch_arm,
> ! 1
> },
> {
> "epoc-pei-arm-little",
>
>