Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 X-Injected-Via-Gmane: http://gmane.org/ To: cygwin AT cygwin DOT com From: Nicholas Wourms Subject: Re: Possible bug with __attribute__((alias)) in gcc-3.3 Date: Wed, 03 Dec 2003 15:46:13 -0500 Lines: 77 Message-ID: References: <20031124074553 DOT 6674 DOT qmail AT web21408 DOT mail DOT yahoo DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en In-Reply-To: <20031124074553.6674.qmail@web21408.mail.yahoo.com> X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Danny Smith wrote: > Nicholas wrote: > > One problem is that you (or gcc) need to tell ld that 'foo' is function, not > data. I'll be the first to admit that I'm almost totally w/o a clue when it comes to assembly. I'm afraid the gas manual is not very helpful in my effort to alleviate this :-(. > Adding this to file foo.c (after the alias declaration): > __asm__ (".def _foo; .scl 2; .type 32; .endef\n"); > would do that. > > That fixes the testcase on mingw anyway. Yes! Thanks, this helps a ton! I can confirm it works in native Cygwin, too. > I'm testing a patch now that would make gcc do that too (for aliased > functions). Cool deal, I look forward to trying it. I only wish gas could better handle converting what I assume to be ELF syntax. This is often the case in other projects, for example from MySQL's strings-x86.s: .globl bmove_allign .type bmove_allign,@function bmove_allign: ... ... .end: .size bmove_allign,.end-bmove_allign Yes, this wish is pure laziness, but it would save time and make more asm code work OOTB if gas could deal with it. > However, in general,when you do dllexport with code written in straight > assembler, you will need to add a function directive like the one above > so that the linker does the right thing. For the archives and in case anyone was curious, here's what I've devised (until your patch to gcc gets in) for {weak,strong}_alias macros: #define weak_alias(name, aliasname) strong_alias(name, aliasname) #define strong_alias(name, aliasname) \ extern __typeof__(name) aliasname __attribute__((__alias__(#name))); \ __asm__(".def \"_" #aliasname "\"; .scl 2; .type 32; .endef\n"); After your patch gets in, I'll drop the third line. Again, I'm in uncharted territory, but... If you think it looks ok, I would like to add these compatibility macros to Cygwin's sys/cdefs.h. This is assuming that the values in .scl and .type remain static for PE-32bit. Feel free to add them to MingW, as well, if you want. Why should we have them, one might ask? Frankly, because having to type out all that crap for each project takes too long and too much effort. I imagine this is why GNU & BSD put them in system headers in the first place. Bind is just one example of what happens when you don't have these macros. Just #define'ing the aliases in headers won't cut it because this will break some autoconf scripts or builds if the function is implicitly used by them (which I believe is the case for AC_CHECK_LIB). > (BTW, you've just reminded me of a similar problem in libffi assembly code > that needs to be fixed. Thanks ) No problem, glad to help ;-). Cheers, Nicholas -- 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/