X-Spam-Check-By: sourceware.org Date: Sat, 03 Feb 2007 23:33:00 +1300 From: Danny Smith Subject: dllimport and __asm__("_alias" ) To: Cygwin , mingw-users AT lists DOT sourceforge DOT net Message-id: <000001c7477e$aeb57f10$df6d65da@anykey> MIME-version: 1.0 X-Mailer: Microsoft Outlook, Build 10.0.2627 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hello, I would appreciate help with While working on some dllimport problems with aliased symbols, I ran across this inconsistency with gcc (all versions) The use of a literal asmspec to rename a static lib symbol (say "bar"), extern void foo (void) __asm__("_bar"); void call_bar(void) { foo(); } does the right thing. The literal is treated as a verbatim asm name, so explicitly adding the '_' USER_LABEL_PREFIX to "bar" is necesssry: _call_bar: pushl %ebp movl %esp, %ebp popl %ebp jmp _bar However,if we try to alias a dllimport'd symbol, like so extern __declspec(dllimport) void foo (void) __asm__("_bar"); void call_bar(void) { foo(); } The literal is not treated as verbatim, but _imp_ prefix as well as additional USER_LABEL_PREFIX to bar is generated _call_bar: pushl %ebp movl __imp___bar, %ecx <<< 3 underscores betweem imp and bar movl %esp, %ebp popl %ebp jmp *%ecx The above will lead to link error if the user name for the exported symbol is "bar". My feeling is that to avoid confusion, an asmspec'd alias should really,really always be verbatim, no adding import prefix, stdcall suffix, nor C++mangling, nothing. That is the way gcc works on other targets. That is, to do the right thing, we would need to: extern __declspec(dllimport) void foo (void) __asm__("__imp__bar"); void call_bar(void) { foo(); } to get _call_bar: pushl %ebp movl __imp__bar, %ecx movl %esp, %ebp popl %ebp jmp *%ecx Any comments, before I submit the patch to gcc? Should gcc warn if the asmspec of a dllimport alias lacks the "__imp__". Danny -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/