This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: 64bit: weak symbols
- From: Earnie Boyd <earnie at users dot sourceforge dot net>
- To: cygwin-developers at cygwin dot com, Kai Tietz <ktietz at redhat dot com>, Dave Korn <dave dot korn dot cygwin at gmail dot com>
- Date: Sun, 31 Mar 2013 13:26:59 -0400
- Subject: Re: 64bit: weak symbols
- References: <CAGvSfez95-FqQ+pLT7MWqYahwqSAWB9v3guHsKfLuj=Jy8r8FQ at mail dot gmail dot com> <20130331103208 dot GG11950 at calimero dot vinschen dot de>
On Sun, Mar 31, 2013 at 6:32 AM, Corinna Vinschen wrote:
> On Mar 30 22:32, Yaakov (Cygwin/X) wrote:
>> The following code links behaves on i686 and x86_64:
>>
>> /* from gcc config/weakref.m4, used in libitm */
>> extern void fNotToBeFound(void) __attribute__((weak));
>> int main ()
>> {
>> if (fNotToBeFound)
>> return 1;
>> else
>> return 0;
>> }
>>
>> On i686 with gcc-4.5.3, this links and returns 0. On x86_64 with
>> gcc-4.8.0, this produces an error:
>>
>> /tmp/ccPWiz9s.o:test.c:(.rdata$.refptr.fNotToBeFound[.refptr.fNotToBeFound]+0x0):
>> undefined reference to `fNotToBeFound'
>> collect2: error: ld returned 1 exit status
>
> There's a recent discussion aboout this very problem on the gcc mailing
> list. Kai claims that weak symbols cannot work this way on PE/COFF
> targets, and the fact that they worked on i686 is kind of a coincidence,
> Dave Korn thinks everything's ok as is. IIUC, the symbol is an absolute
> reference to the 0 address on i686, but a pc-relative reference with
> undefined displacement on x86_64. Personally I think the x86_64 gcc
> should create absolute references for weak symbols as well, but I'm not
> fluent enough in the bowels of gcc to have a say in the matter.
Regardless, IMO, the result should be the same for either i686 or x86_64.
--
Earnie
-- https://sites.google.com/site/earnieboyd