Need help figuring out DLL load problem

Danny Backx danny.backx@scarlet.be
Sun Aug 2 12:22:00 GMT 2009


On Thu, 2009-07-30 at 20:56 +0100, Dave Korn wrote:
> Danny Backx wrote:
> 
> > The Import Tables (interpreted .idata section contents)
> >  vma:            Hint    Time      Forward  DLL       First
> >                  Table   Stamp     Chain    Name      Thunk
> 
> >  00004014       000040c4 00000000 00000000 000042b0 00004130
> > 
> >         DLL Name: libstdc++-6.dll
> >         vma:  Hint/Ord Member-Name Bound-To
> >         41e4     2744  _ZNSt8ios_base4InitC1Ev
> >         4200     2746  _ZNSt8ios_base4InitD1Ev
> >         421c     2984  _ZSt4cout
> >         4228     3060
> > _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
> 
> >  00004050       000040e8 00000000 00000000 000042b0 0000109a
> > 
> >         DLL Name: libstdc++-6.dll
> >         vma:  Hint/Ord Member-Name Bound-To
> >         41e4     2744  _ZNSt8ios_base4InitC1Ev
> 
>   That confirms my theory.  The call at 0x00401099 should go to
> _imp___ZNSt8ios_base4InitC1Ev at 0x404130, but then the auto-import fixup
> relocation goes and gets applied to it.  The resulting address should be the sum
> of the real address and the import stub address, so
> 
>   0x423517be = _ZNSt8ios_base4InitC1Ev + 0x404130
> 
> or in other words, _ZNSt8ios_base4InitC1Ev = 0x41F4D68E, which is inside the
> DLL's address range as it should be.
> 
>   Your mission then is to figure out why LD is generating an auto-import fixup
> entry, when this is not a data reference.  Take a look at pe_find_data_imports()
> in ld/emultempl/pe.em, that's where they all get generated.

Maybe you can help me understand what's going on, I lack knowledge.

I am including three pieces of information :
1. diffs I applied to emultempl/pe.em to be more verbose
2. output of that from the ill-behaving i386-mingw32ce-ld
3. output of that from arm-mingw32ce-ld which does work

Commands used :
arm-mingw32ce-g++ -c -o hello2arm.o hello.C
i386-mingw32ce-g++ -c -o hello2.o hello.C
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/build-x86-mingw32ce/binutils/ld/ld-new \
        --enable-extra-pe-debug \
        -Bdynamic -o hello2.exe \
        /opt/x86mingw32ce/i386-mingw32ce/lib/crt3.o \
        -L/opt/x86mingw32ce/lib/gcc/i386-mingw32ce/4.4.0 \
        -L/opt/x86mingw32ce/i386-mingw32ce/lib --enable-auto-import
hello2.o \
        -lstdc++ -lmingw32 -lgcc_s -lgcc -lceoldname -lmingwex -lcoredll
\
        -lmingw32 -lgcc_s -lgcc -lceoldname -lmingwex \
        /opt/x86mingw32ce/lib/gcc/i386-mingw32ce/4.4.0/crtend.o \
        >&ld.out.i386
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/build-mingw32ce/binutils/ld/ld-new \
        --enable-extra-pe-debug \
        -Bdynamic -o hello2arm.exe \
        /opt/mingw32ce/arm-mingw32ce/lib/crt3.o \
        -L/opt/mingw32ce/lib/gcc/arm-mingw32ce/4.4.0 \
        -L/opt/mingw32ce/arm-mingw32ce/lib --enable-auto-import
hello2arm.o \
        -lstdc++ -lmingw32 -lgcc_s -lgcc -lceoldname -lmingwex -lcoredll
\
        -lmingw32 -lgcc_s -lgcc -lceoldname -lmingwex \
        /opt/mingw32ce/lib/gcc/arm-mingw32ce/4.4.0/crtend.o \
        >&ld.out.arm


What confuses me is that the ld output files appear to indicate
different input, see the first couple of lines in the output (before
gld_arm_wince_pe_after_open and gld_i386pe_after_open).

This appears to indicate different input symbol lists. The difference
contains one of the symbols we're chasing : __ZNSt8ios_base4InitC1Ev .

Is this meaningful, or is another part of the output key to the answer ?

	Danny

-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
-------------- next part --------------
Yow (pe_find_data_imports) link_info.pei386_auto_import 1
Yow sym {_ZSt4cout} undef->type 1 (undefined)
Yow sym {_ZSt4cout} link_info.pei386_auto_import 1
Yow sym {__image_base__} undef->type 1 (undefined)
Yow sym {__CTOR_LIST__} undef->type 1 (undefined)
Yow sym {__DTOR_LIST__} undef->type 1 (undefined)
Yow sym {__libcoredll_a_iname} undef->type 3 (defined)
gld_arm_wince_pe_after_open()
-_ZSt4cout
-__image_base__
-__CTOR_LIST__
-__DTOR_LIST__
-__libcoredll_a_iname
+_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+__atexit_first
+_cexit
+__mingw_do_global_ctors
+wcslen
+__imp_strspn
+_nm__ZSt4cout
+GetModuleFileNameW
+malloc
+TerminateProcess
+__gccmain
+_head_libstdc___6_dll
+__imp__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+_fcloseall
+__imp_free
+wcstombs
+fflush
+_fpreset
+__imp__fcloseall
+__image_base__
+__RUNTIME_PSEUDO_RELOC_LIST__
+__argc
+__dll_exit
+__libcoredll_a_iname
+__CTOR_LIST__
+libstdc___6_dll_iname
+__imp_TerminateProcess
+__argv
+realloc
+__imp_strlen
+__imp_malloc
+__imp__fpreset
+_ZNSt8ios_base4InitC1Ev
+__imp__ZNSt8ios_base4InitD1Ev
+__imp_realloc
+main
+WinMain
+_c_exit
+__DTOR_LIST__
+_pei386_runtime_relocator
+atexit
+strcspn
+__imp_strcspn
+__imp_wcstombs
+WinMainCRTStartup
+__imp_GetModuleFileNameW
+_ZNSt8ios_base4InitD1Ev
+_head_libcoredll_a
+__imp__ZSt4cout
+__imp_strchr
+_ZSt4cout
+__imp_wcslen
+_onexit
+exit
+__imp_fflush
+__atexit_init
+_exit
+strspn
+strlen
+__imp__ZNSt8ios_base4InitC1Ev
+__mingw_do_global_dtors
+strchr
+__RUNTIME_PSEUDO_RELOC_LIST_END__
+__dllonexit
+free
*/opt/mingw32ce/arm-mingw32ce/lib/crt3.o
*hello2arm.o
*d002986.o
*d003062.o
*d002746.o
*d002748.o
*d000000.o
*d003810.o
*pseudo-reloc.o
*atexit.o
*gccmain.o
*winmain_ce.o
*pseudo-reloc-list.o
*dwcks01277.o
*dwcks01120.o
*dwcks01552.o
*dwcks01415.o
*dwcks01398.o
*dwcks01269.o
*dwcks01503.o
*dwcks00434.o
*dwcks01637.o
*dwcks01648.o
*dwcks01569.o
*dwcks01568.o
*dwcks01575.o
*dwcks01565.o
*dwckh.o
*dwckt.o
*/opt/mingw32ce/lib/gcc/arm-mingw32ce/4.4.0/crtend.o
pe_fixup_stdcalls
pe_find_data_imports:_ZSt4cout
->_head_libstdc___6_dll
arelent: _ZSt4cout@0x34: add=0
Yow reloc for __fu0__ZSt4cout (addend=0)
pe_find_data_imports:__image_base__
pe_find_data_imports:__CTOR_LIST__
pe_find_data_imports:__DTOR_LIST__
-------------- next part --------------
Yow (pe_find_data_imports) link_info.pei386_auto_import 1
Yow sym {__ZSt4cout} undef->type 1 (undefined)
Yow sym {__ZSt4cout} link_info.pei386_auto_import 1
Yow sym {__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc} undef->type 1 (undefined)
Yow sym {__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc} link_info.pei386_auto_import 1
Yow sym {__ZNSt8ios_base4InitC1Ev} undef->type 1 (undefined)
Yow sym {__ZNSt8ios_base4InitC1Ev} link_info.pei386_auto_import 1
Yow sym {__ZNSt8ios_base4InitD1Ev} undef->type 1 (undefined)
Yow sym {__ZNSt8ios_base4InitD1Ev} link_info.pei386_auto_import 1
Yow sym {__image_base__} undef->type 1 (undefined)
Yow sym {___CTOR_LIST__} undef->type 5 (common)
Yow sym {___DTOR_LIST__} undef->type 5 (common)
Yow sym {__libcoredll_a_iname} undef->type 3 (defined)
gld_i386pe_after_open()
-__ZSt4cout
-__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
-__ZNSt8ios_base4InitC1Ev
-__ZNSt8ios_base4InitD1Ev
-__image_base__
-___CTOR_LIST__
-___DTOR_LIST__
-__libcoredll_a_iname
+__cexit
+__fcloseall
+___RUNTIME_PSEUDO_RELOC_LIST__
+_strcspn
+__exit
+___DTOR_LIST__
+_free
+_WinMain
+___mingw_do_global_dtors
+__nm___ZSt4cout
+__nm___ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+__imp___fcloseall
+__ZNSt8ios_base4InitC1Ev
+__imp__strspn
+___RUNTIME_PSEUDO_RELOC_LIST_END__
+__fpreset
+_WinMainCRTStartup
+__imp__wcstombs
+__imp__wcslen
+__imp___ZNSt8ios_base4InitD1Ev
+__ZSt4cout
+___argv
+__image_base__
+_wcstombs
+___mingw_do_global_ctors
+__libcoredll_a_iname
+___dll_exit
+___atexit_init
+_fflush
+__imp___ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+__head_libcoredll_a
+__imp___ZNSt8ios_base4InitC1Ev
+_wcslen
+__imp__strchr
+__imp__GetModuleFileNameW
+__head_libstdc___6_dll
+___CTOR_LIST__
+___atexit_first
+_realloc
+__imp__malloc
+__imp__realloc
+__pei386_runtime_relocator
+__nm___ZNSt8ios_base4InitD1Ev
+_strchr
+___gccmain
+___dllonexit
+__imp__TerminateProcess
+__c_exit
+_malloc
+__imp___fpreset
+__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+_strspn
+_atexit
+__imp__fflush
+_TerminateProcess
+__onexit
+__nm___ZNSt8ios_base4InitC1Ev
+__imp__free
+_libstdc___6_dll_iname
+_exit
+__imp__strcspn
+_GetModuleFileNameW
+__imp___ZSt4cout
+__ZNSt8ios_base4InitD1Ev
+_main
+___argc
*/opt/x86mingw32ce/i386-mingw32ce/lib/crt3.o
*hello2.o
*d002985.o
*d003061.o
*d002745.o
*d002747.o
*d000000.o
*d003809.o
*pseudo-reloc.o
*atexit.o
*gccmain.o
*winmain_ce.o
*pseudo-reloc-list.o
*_ctors.o
*dknubs01282.o
*dknubs01125.o
*dknubs01557.o
*dknubs01420.o
*dknubs01403.o
*dknubs01274.o
*dknubs01508.o
*dknubs00439.o
*dknubs01642.o
*dknubs01653.o
*dknubs01580.o
*dknubs01573.o
*dknubs01570.o
*dknubh.o
*dknubt.o
*/opt/x86mingw32ce/lib/gcc/i386-mingw32ce/4.4.0/crtend.o
pe_fixup_stdcalls
pe_find_data_imports:__ZSt4cout
->__head_libstdc___6_dll
arelent: __ZSt4cout@0x19: add=0
Yow reloc for __fu0___ZSt4cout (addend=0)
pe_find_data_imports:__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
->__head_libstdc___6_dll
arelent: __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@0x1e: add=0
Yow reloc for __fu1___ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc (addend=0)
pe_find_data_imports:__ZNSt8ios_base4InitC1Ev
->__head_libstdc___6_dll
arelent: __ZNSt8ios_base4InitC1Ev@0x46: add=0
Yow reloc for __fu2___ZNSt8ios_base4InitC1Ev (addend=0)
pe_find_data_imports:__ZNSt8ios_base4InitD1Ev
->__head_libstdc___6_dll
arelent: __ZNSt8ios_base4InitD1Ev@0x61: add=0
Yow reloc for __fu3___ZNSt8ios_base4InitD1Ev (addend=0)
pe_find_data_imports:__image_base__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: emultempl-pe.em-diff
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20090802/b8e5d7b7/attachment.bin>


More information about the Binutils mailing list