From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36900 invoked by alias); 24 Mar 2016 00:52:48 -0000 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 Received: (qmail 36274 invoked by uid 89); 24 Mar 2016 00:52:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*MI:sk:H6230cW, H*MI:sk:9106B2F, H*f:sk:H6230cW, swift X-HELO: mail-in4.apple.com Received: from mail-out4.apple.com (HELO mail-in4.apple.com) (17.151.62.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 24 Mar 2016 00:52:37 +0000 Received: from relay3.apple.com (relay3.apple.com [17.128.113.83]) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id 5D.5E.21445.35A33F65; Wed, 23 Mar 2016 17:52:35 -0700 (PDT) Received: from nwk-mmpp-sz08.apple.com (nwk-mmpp-sz08.apple.com [17.128.115.25]) (using TLS with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by relay3.apple.com (Apple SCV relay) with SMTP id 20.4B.12923.25A33F65; Wed, 23 Mar 2016 17:52:35 -0700 (PDT) Received: from [17.153.39.148] by nwk-mmpp-sz08.apple.com (Oracle Communications Messaging Server 7.0.5.35.0 64bit (built Mar 31 2015)) with ESMTPSA id <0O4I00BVVQFKWW80@nwk-mmpp-sz08.apple.com> for binutils@sourceware.org; Wed, 23 Mar 2016 17:52:34 -0700 (PDT) Content-type: text/plain; charset=us-ascii MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Preventing preemption of 'protected' symbols in GNU ld 2.26 From: Joe Groff In-reply-to: Date: Thu, 24 Mar 2016 00:52:00 -0000 Cc: Binutils Content-transfer-encoding: quoted-printable Message-id: References: <9106B2FB-BB06-413A-A04D-EEFB992784FA@apple.com> To: "H.J. Lu" X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00314.txt.bz2 > On Mar 23, 2016, at 5:45 PM, H.J. Lu wrote: >=20 > On Wed, Mar 23, 2016 at 5:00 PM, Joe Groff wrote: >> Hi everyone. On the Swift project, we're getting bug reports that people= are no longer able to link Swift programs using binutils 2.26: >>=20 >> https://bugs.swift.org/browse/SR-1023 >>=20 >> This appears to be due to an intentional behavior change in commit https= ://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;a=3Dcommit;h=3Dca3fe9= 5e469b9daec153caa2c90665f5daaec2b5, to allow protected symbols to be the ta= rgets of copy relocations. This breaks our intended use of "protected" in S= wift, where we really want to be able to assume that the relative addresses= of our symbols within a single executable or .so won't be preempted or mov= ed. This lets us emit position-independent constant reflection metadata tha= t doesn't need load-time relocations, saving us some startup time and dirty= pages. I wanted to know if there's a supported way to express to the linke= r that "this symbol is protected, and also can never be copied". I'd like t= o avoid globally setting -Bsymbolic since I wouldn't want to impact non-Swi= ft .o files in a mixed-language project. AIUI, -Bsymbolic also wouldn't pre= vent object files from trying to use copy relocations to our symbols and br= eaking our assumptions about their address; I'd like to know if it's possib= le to prevent that too. Thanks for any help you can give! >>=20 >=20 > What you want is not protected symbol, which is expensive to lookup > at run-time. You need: >=20 > -z nocopyreloc Don't create copy relocs >=20 > But it requires that everything must be compiled with -fPIC, not even > -fPIE, for both executable and shared library. Otherwise, you will > get dynamic relocations in text section. >=20 > Swift should do something like -fPIC-data, to access external data via > PIC. Then you can pass >=20 > -z nocopyreloc Don't create copy relocs >=20 > to linker. Thanks H.J. Is it possible to specify this in the object file, at the symbo= l level, or does "nocopyreloc" have to be specified by linker flags? -Joe