public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* arm-wince-pe, dll auto-importing broken when
@ 2006-05-05  1:49 Pedro Alves
  2006-05-05  2:03 ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2006-05-05  1:49 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-05-05 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-05  1:49 arm-wince-pe, dll auto-importing broken when Pedro Alves
2006-05-05  2:03 ` Pedro Alves
2006-05-05  2:17   ` Daniel Jacobowitz
2006-05-05  2:35     ` Pedro Alves
2006-05-05  2:50       ` Pedro Alves
2006-05-05 13:14         ` Daniel Jacobowitz
2006-05-05 16:49           ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).