delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/24/19:28:55

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <20000724232744.44516.qmail@hotmail.com>
X-Originating-IP: [203.97.2.246]
From: "Danny Smith" <danny_r_smith AT hotmail DOT com>
To: <cygwin AT sources DOT redhat DOT com>
Subject: ld -shared and @ordinals in .def files
Date: Tue, 25 Jul 2000 11:18:58 +1200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600

Hi

ld -shared (prerelease binutils-20000722-1) appears to ignore the
ordinal values supplied in a .def when building dlls.

For example (modified from Mumit's dllhelpers-0.2.5/c):

This def (mycdll.def)

EXPORTS
 dll_global_int_var @1 DATA
 dll_int_square @2
 dll_set_global_int_var @3
 dll_double_square @4
 dll_get_global_int_var @5
 dll_float_square @6

and this command

    gcc -shared -Wl,--out-implib,libimpcdll.a mycdll.def cdll.o
dllinit.o

successfully builds a working dll and import lib.

But this is what is in the dll (partial output from Dependency Walker
2.0):

     Export  Ordinal     Hint        Function                Entry Point
     ------  ----------  ----------  ----------------------  -----------
     [C  ]   1 (0x0001)  1 (0x0001)  dll_float_square        0x00001074
     [C  ]   2 (0x0002)  2 (0x0002)  dll_get_global_int_var  0x00001094
     [C  ]   3 (0x0003)  3 (0x0003)  dll_global_int_var      0x00003000
     [C  ]   4 (0x0004)  4 (0x0004)  dll_int_square          0x00001048
     [C  ]   5 (0x0005)  5 (0x0005)  dll_set_global_int_var  0x00001084
     [C  ]   6 (0x0006)  0 (0x0000)  dll_double_square       0x0000105C

The ordinals do not match what was requested.  This occurs when using
only the def file to mark symbols for export and when using
__declspec(dllexport) in code +  a user-supplied .def.

Using dllwrap:
dllwrap --def mycdll.def --implib libimpcdll.a  -o cdll.dll cdll.o
dllinit.o

The ordinals are as requested:

     Export  Ordinal     Hint        Function                Entry Point
     ------  ----------  ----------  ----------------------  -----------
     [C  ]   1 (0x0001)  3 (0x0003)  dll_global_int_var      0x00002000
     [C  ]   2 (0x0002)  4 (0x0004)  dll_int_square          0x00001048
     [C  ]   3 (0x0003)  5 (0x0005)  dll_set_global_int_var  0x00001084
     [C  ]   4 (0x0004)  0 (0x0000)  dll_double_square       0x0000105C
     [C  ]   5 (0x0005)  2 (0x0002)  dll_get_global_int_var  0x00001094
     [C  ]   6 (0x0006)  1 (0x0001)  dll_float_square        0x00001074



[BTW I have found Dependency Walker (depends.exe) a very useful tool to
sort out problems with dlls, and can trace explicit run-time calls
(LoadLibrary/GetProcAddress) as well as load-time links.  Latest version
(improved over the one that ships with MSVC++6)  can be downloaded from
the author at:
http://stevemiller.net/apps.html ]



Regards

Danny


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019