This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin 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]

RE: ordinal linking for cygwin ld


> a self
> > written rebind app and got a problem.
> >
> > rebind does only patch the first IAT entry, if the dll is created with
> ld. The
> > others are set to zero ????
> >
> > Rebinding for example the cygwin1.dll to some natvie windows apps
> works, so this
> > seems to be an ld incompatiblity.
> >
> > Does anyone have got experience in such binding stuff ?
>
> No, but perhaps it's the auto-import duplicates that cause the problem?

No. I have checked this by a dll without vars. See below:

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00004000       00004054 00000000 00000000 0000420c 00004074

        DLL Name: dll.dll
        vma:  Hint/Ord Member-Name
        40dc        0  printfunc0000__1Av
        40f4        1  printfunc0001__1Av
        410c        2  printfunc0002__1Av
        4124        3  printfunc0003__1Av
        413c        4  printfunc0004__1Av

 00004014       00004070 00000000 00000000 00004230 000040a8

        DLL Name: cygwin1.dll
        vma:  Hint/Ord Member-Name
        4154       26  __main
        4160      581  calloc
        416c      634  cygwin_internal
        4180      652  dll_crt0__FP11per_process
        419c      722  free
        41a4      876  malloc
        41b0     1006  realloc
        The Import Address Table is identical

 00004028       00004094 00000000 00000000 00004248 000040cc

        DLL Name: KERNEL32.dll
        vma:  Hint/Ord Member-Name
        41bc      248  GetCurrentProcess
        41d0      296  GetModuleHandleA
        41e4      661  TerminateProcess
        The Import Address Table is identical

--------------------------------------------------------------------------------
------
rebinding client.exe
--------------------------------------------------------------------------------
------
rebind client.exe ./
rebind - message: client.exe dll.dll Module import is starting.
rebind - message: client.exe dll.dll Procedure import is starting.
printfunc0000__1Av
rebind - message: client.exe dll.dll Procedure import failed. printfunc0000__1Av

He has patched, which you can see below, but break after this.

rebind - message: client.exe cygwin1.dll Module import failed. -> not found.
okay
rebind - message: client.exe KERNEL32.dll Module import failed. -> not found.
okay
rebind - message: client.exe (null) Image modified.
BIND: Details of binding client.exe
    Import from dll.dll [6]
                    ^^^^^^^^^
    Import from cygwin1.dll [0]
    Import from KERNEL32.dll [0]
rebind 2
--------------------------------------------------------------------------------
------
The Import Tables (interpreted .idata section contents)

 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00004000       00004054 ffffffff ffffffff 0000420c 0004074

        DLL Name: dll.dll
        vma:  Hint/Ord Member-Name
        40dc        0  printfunc0000__1Av       0001
        40f4        1  printfunc0001__1Av       0004
        410c        2  printfunc0002__1Av       0000
        4124        3  printfunc0003__1Av       8000
        413c        4  printfunc0004__1Av       0400
--------------------------------------------------------------------------------
------
rebinding cygwin1.dll
--------------------------------------------------------------------------------
------
$ rebind ./client.exe /bin
rebind client.exe c:\programme\cygwin\bin
rebind - message: client.exe dll.dll Module import is starting.
rebind - message: client.exe dll.dll Procedure import is starting.
printfunc0000__1Av
rebind - message: client.exe dll.dll Procedure import failed. printfunc0000__1Av
rebind - message: client.exe cygwin1.dll Module import is starting.
rebind - message: client.exe c:\programme\cygwin\bin\cygwin1.dll Procedure
import is starting. __main
rebind - message: client.exe c:\programme\cygwin\bin\cygwin1.dll Procedure
import failed. __main
rebind - message: client.exe KERNEL32.dll Module import failed.
rebind - message: client.exe (null) Image modified.
BIND: Details of binding client.exe
    Import from dll.dll [6]
    Import from cygwin1.dll [6]
    Import from KERNEL32.dll [0]
--------------------------------------------------------------------------------
------

 00004014       00004070 ffffffff ffffffff 00004230 000040a8

        DLL Name: cygwin1.dll
        vma:  Hint/Ord Member-Name
        4154       26  __main   61004308
        4160      581  calloc   0000
        416c      634  cygwin_internal  0000
        4180      652  dll_crt0__FP11per_process        0000
        419c      722  free     0000
        41a4      876  malloc   0000
        41b0     1006  realloc  0000
--------------------------------------------------------------------------------
------
                                ^^^^^^
Do you see this ? The first is set correct, the other set to zero.

The masin difference I see currently are differences in the data directory
relating entry c, which is defined on native dll's and not for ld builded dll#s

ChkRes2K.dll
The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00013fe0 0000008c Import Directory [parts of .idata]
Entry 2 0001b000 00003a00 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00011000 00000394 Import Address Table Directory
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved


my client.exe

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00004000 00000258 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
         ^^^^^^^^^^^^^^
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved


after rebinding client.exe

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00004000 00000258 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000268 00000044 Bound Import Directory
           ^^^^^^^^^^^^^^^^
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

Ralf



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