From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 798 invoked by alias); 24 Mar 2016 00:45:47 -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 769 invoked by uid 89); 24 Mar 2016 00:45:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=relocs, Preventing, swift, joe X-HELO: mail-qk0-f175.google.com Received: from mail-qk0-f175.google.com (HELO mail-qk0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 24 Mar 2016 00:45:34 +0000 Received: by mail-qk0-f175.google.com with SMTP id p130so14055340qke.1 for ; Wed, 23 Mar 2016 17:45:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=1e3+qZTNkePErbA5LSOV7zGW6ee0rlt8fVWAAWvQ1rY=; b=XLNTA42lqwda3NBNajXFVhaCLUtngenlaBPY5aoB7+JM6Vjnwa8BgSkxEPUg7Rl5k4 i6tZgfEApM2EO3senLamc14/0gZe4Tn0mq1JV1pzk+NIW4sedqFKJ5L/QpUegiRZFEx4 VwdTqQV8sccZmxrdtGhhZK2kBIEOB8tq7ankoePHJIeuHPYRj1TiipieTx+nlvPgU0KH TrpXLUwdx/iyOQfIInmcuV16N4xJCw8xXin4s/vmtF16mX5Sgx9WdAxfvOzCIHs9qE3A WCcSzYEjNG+qImRfr9IICLVP6p8WQEZ9Y3bsTp+lsS7+UyriFQYez4NJvbwf0oc4jSea FdKA== X-Gm-Message-State: AD7BkJLPpYE1WjVQiS3RXioHWGbIxXRG5+gW/mgZydrNuTVHIc1ZvlKsLrdfNPECcYEGklIiUr8BcdgTvveE2g== MIME-Version: 1.0 X-Received: by 10.55.80.131 with SMTP id e125mr7275728qkb.62.1458780331886; Wed, 23 Mar 2016 17:45:31 -0700 (PDT) Received: by 10.55.57.203 with HTTP; Wed, 23 Mar 2016 17:45:31 -0700 (PDT) In-Reply-To: <9106B2FB-BB06-413A-A04D-EEFB992784FA@apple.com> References: <9106B2FB-BB06-413A-A04D-EEFB992784FA@apple.com> Date: Thu, 24 Mar 2016 00:45:00 -0000 Message-ID: Subject: Re: Preventing preemption of 'protected' symbols in GNU ld 2.26 From: "H.J. Lu" To: Joe Groff Cc: Binutils Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00313.txt.bz2 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: > > https://bugs.swift.org/browse/SR-1023 > > 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=3Dca3fe95= e469b9daec153caa2c90665f5daaec2b5, to allow protected symbols to be the tar= gets of copy relocations. This breaks our intended use of "protected" in Sw= ift, 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 move= d. This lets us emit position-independent constant reflection metadata that= 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 linker= that "this symbol is protected, and also can never be copied". I'd like to= avoid globally setting -Bsymbolic since I wouldn't want to impact non-Swif= t .o files in a mixed-language project. AIUI, -Bsymbolic also wouldn't prev= ent object files from trying to use copy relocations to our symbols and bre= aking our assumptions about their address; I'd like to know if it's possibl= e to prevent that too. Thanks for any help you can give! > What you want is not protected symbol, which is expensive to lookup at run-time. You need: -z nocopyreloc Don't create copy relocs 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. Swift should do something like -fPIC-data, to access external data via PIC. Then you can pass -z nocopyreloc Don't create copy relocs to linker. --=20 H.J.