From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26224 invoked by alias); 23 May 2011 16:16:43 -0000 Received: (qmail 26131 invoked by uid 22791); 23 May 2011 16:16:41 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 16:16:29 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4NGGAvd010184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 May 2011 12:16:10 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4NGG91l004981; Mon, 23 May 2011 12:16:09 -0400 Received: from [10.3.113.87] (ovpn-113-87.phx2.redhat.com [10.3.113.87]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p4NGG8jK007472; Mon, 23 May 2011 12:16:08 -0400 Message-ID: <4DDA8847.2070405@redhat.com> Date: Mon, 23 May 2011 16:16:00 -0000 From: Jeff Law User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Nick Clifton CC: aoliva@redhat.com, rth@redhat.com, gcc-patches@gcc.gnu.org, binutils@sourceware.org Subject: Re: RFC/RFA: MN10300: Fix handling of protected functions in shared libraries. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00310.txt.bz2 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/23/11 09:21, Nick Clifton wrote: > Hi Alex, Hi Jeff, Hi Richard, > > Consider the following small test case: > > % cat test1.c > extern int g (void) __attribute__ ((visibility("protected"))); > int f (void) { return g (); } > > % cat test2.c > extern int g(void) __attribute__ ((visibility("protected"))); > int i; > int g (void) { return i; } > > % gcc -fPIC -c test1.c test2.c > % gcc -shared -o libtest_protected.so test1.o test2.o > > When compiled with a MN10300 toolchain based on the current FSF GCC > and binutils sources the final link will fail with: > > test1.o: In function `f': > test1.c:(.text+0x7): warning: error: inappropriate relocation type for shared library (did you forget -fpic?) > > The problem here is that GCC has decided that since "g" is protected > it does not need a PLT entry. But the linker has decided that since > "g" is a function it does need a PLT entry (even though it is > protected) so that function pointer comparison will work. (See the > definition of SYMBOL_REFERENCES_LOCAL in bfd/elf-bfd.h for more > information on this). > > I have a small patch that fixes this problem (see below), but I am not > sure if this is the correct solution. As far as I can see, this is > not an MN10300 specific problem however, so surely other targets ought > to have similar problems ? (But other targets do not seem to use > targetm.binds_local_p to decide if a symbol is global or local. cf/ > mn10300_encode_section_info). > > Anyway any advice or comments on the situation would be appreciated. This isn't something I have much experience with; presumably we must have the PLT entry even though "g" is considered protected? If so, then ISTM GCC will need to cope/adapt and your approach seems as good as any other to me -- unless we wanted to move the code into a more generic location. jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJN2ohHAAoJEBRtltQi2kC7lpcH/ihLGKBhkB7PG2ZjkXZJBH2l WMuG7lVDSKiveqLTCI5o4bXRue2Xt+cusYGn/+nUGv5oMfPZCb5qmypT58e0IvVM w1oFks9X+0DyhuIQ0gD4BEbS+R36KkkMlnI4zGqpUq4J+i6XJFIrurw4DghJ22Pe tU7P7C7+uUeAH5f/Be3QIx1MNl0BnruyzPRSrXzGnrg5DP6yyXdwE8SmAhqEuUvJ UkTqT1HWDVgS1eN+lh8tHUUu2ygqoTELpVOwVkvTXP1qrJKmwgbV+3Tvu8jMfvYJ olm2HWUINPX2zvlaqfYUNB+5gFifkqVg7JXOF+NUasaUZwPIiReGaxbsRSFt7Ug= =zrdM -----END PGP SIGNATURE-----