delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/24/02:46:05

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20031124074553.6674.qmail@web21408.mail.yahoo.com>
Date: Mon, 24 Nov 2003 18:45:53 +1100 (EST)
From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001 AT yahoo DOT co DOT nz>
Subject: RE: Possible bug with __attribute__((alias)) in gcc-3.3
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

Nicholas wrote:

> Hi All,
> 
> Gerrit and I were discussing this off-list, but I thought it appropriate
> that I move it to the main list since he has confirmed the problem.
> 
> Here's the problem, programs are segfaulting when the are linked to a
> symbol which was aliased using __attribute__((alias)) in a dll. Here is
> a small testcase:
> 
> 
> foo.c:
> #include <stdio.h>
> 
> int __foo (void) {
>    printf("foo\r\n");
>    return 0;
> }
> int __attribute__ ((alias("__foo"))) foo (void);
> 

One problem is that you (or gcc) need to tell ld that 'foo' is function, not
data.

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. 

I'm testing a patch now that would make gcc do that too (for aliased 
functions).

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. 

(BTW, you've just reminded me of a  similar problem in libffi assembly code
that needs to be fixed.  Thanks )

Or...
The usual windows way would be to put your aliasing for dllexports in a def
file.

Danny


http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

--
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/

- Raw text -


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