This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

arm-wince-pe, dll auto-importing broken when


Hi all,

Linking against two import libs:
dll 1: import lib generated by MSFT's evc (I think version 4)
dll 2: import lib generated by ld.

Triggers a bug that make auto-imported vars misbehave.

I can see at runtime that the loader isn't processing dll auto-imports from dll 2 correctly.
It is the presence of dll 1 that triggers the bug. Note that this bug never shows up if only implibs generated by ld are used.


Ex:
int __argc is autoimported from dll 2. (cegcc.dll)

At runtime, I get &__argc == 0x000150a8

Which corresponds to:
SORT(*)(.idata$5)
.idata$5 0x000150a4 0x4 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/libcegcc.dll.a(d000000.o)
.idata$5 0x000150a8 0x4 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/libcegcc.dll.a(d000203.o)
0x000150a8 __imp___argc
0x000150a8 __imp___argc


So, the fixups didn't end up resolved correctly. Probably the loader fixed up the wrong address.

I think the problem is related to the fact that the import lib for dll 1 exports __NULL_IMPORT_DESCRIPTOR,
and that ends up in the final executable along the .idata$3 import descriptor terminator generated by ld.


Here is a snippet of the map file:
.idata$2 0x00015028 0x14 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/zlibce.lib(zlibce.dll.a)
0x00015028 __IMPORT_DESCRIPTOR_zlibce
SORT(*)(.idata$3)
.idata$3 0x0001503c 0x14 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/zlibce.lib(zlibce.dll.c)
0x0001503c __NULL_IMPORT_DESCRIPTOR
0x00015050 0x4 LONG 0x0
0x00015054 0x4 LONG 0x0
0x00015058 0x4 LONG 0x0
0x0001505c 0x4 LONG 0x0
0x00015060 0x4 LONG 0x0


If I override __NULL_IMPORT_DESCRIPTOR, by adding a global var:

int __NULL_IMPORT_DESCRIPTOR;

the problem goes away, as ld discards __NULL_IMPORT_DESCRIPTOR from the implib.

The map file looks like this then:
(...)
.idata$2 0x00015028 0x14 /usr/local/lib/gcc/arm-wince-pe/4.1.1/../../../../arm-wince-pe/lib/zlibce.lib(zlibce.dll.a)
0x00015028 __IMPORT_DESCRIPTOR_zlibce
SORT(*)(.idata$3)
0x0001503c 0x4 LONG 0x0
0x00015040 0x4 LONG 0x0
0x00015044 0x4 LONG 0x0
0x00015048 0x4 LONG 0x0
0x0001504c 0x4 LONG 0x0


And at runtime &__argc has the correct address.

Am I right that there should only by 0x14 bytes in idata$3? If yes, where should I look to fix it? Else, any hints on where the problem may be?

Cheers,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]