From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46174 invoked by alias); 29 Mar 2016 12:40:26 -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 46097 invoked by uid 89); 29 Mar 2016 12:40:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1966, 4000, UD:pdf X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Mar 2016 12:40:14 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Websense Email Security Gateway with ESMTPS id 734F4F4DA9B33; Tue, 29 Mar 2016 13:40:09 +0100 (IST) Received: from [10.100.200.215] (10.100.200.215) by hhmail02.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.266.1; Tue, 29 Mar 2016 13:40:11 +0100 Date: Tue, 29 Mar 2016 12:40:00 -0000 From: "Maciej W. Rozycki" To: Cary Coutant CC: "H.J. Lu" , Joe Groff , Binutils Subject: Re: Preventing preemption of 'protected' symbols in GNU ld 2.26 In-Reply-To: Message-ID: References: <9106B2FB-BB06-413A-A04D-EEFB992784FA@apple.com> <9EFBBDCE-4054-4867-B3E9-9DFE216A234F@apple.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2016-03/txt/msg00368.txt.bz2 On Thu, 24 Mar 2016, Cary Coutant wrote: > - Arguing that protected means that the definition is in the same > module but its address might be external is absurd. The *only* reason > for the gABI to make that guarantee is so the compilers can optimize > the code based on the knowledge that the symbol can't be pre-empted. For the record, SGI's original 64-bit MIPS psABI document[1], which is where the concept of symbol's export class aka visibility came from first, before having been adopted by the gABI, has these notes on the semantics of protected symbols: "References to protected symbols (and hence to hidden or internal symbols) may be optimized by using absolute addresses in executables or by assuming addresses to be relatively nearby." and: "An R_MIPS_JALR relocation is intended for optimization of jumps to protected symbols, i.e. symbols which may not be preempted. The word to be relocated is a jump (typically a JALR) to the indicated symbol. If it is not a preemptible symbol (and therefore defined in the current executable/DSO) the relocation is a request to the linker to convert it to a direct branch (typically a JAL in the main executable, or a BGEZAL in DSOs if the target symbol is close enough). The linker must check that the symbol is not preemptible before performing the relocation, but no action is required for correctness -- this is strictly an optimization hint." which clearly indicate the intent for protected symbols to be defined locally, in the same way as hidden and internal symbols are, with the exception of additionally being exported. You can't use a BGEZAL instruction (which is a direct branch with a limited signed 18-bit range) if its target is moved outside the DSO it's in. References: [1] "64-bit ELF Object File Specification, Draft Version 2.5" Maciej