From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51792 invoked by alias); 10 Jun 2016 20:33:56 -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 51780 invoked by uid 89); 10 Jun 2016 20:33:55 -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= X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 10 Jun 2016 20:33:54 +0000 Received: by mail-qk0-f181.google.com with SMTP id p10so11887930qke.3 for ; Fri, 10 Jun 2016 13:33:54 -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:from:date :message-id:subject:to:cc; bh=eOKjsTfoiTE4g8/RXIavE9LASthdXZQXRby9p2ewJPk=; b=OD0fzJKIKU3It8T4Sktiu6t3HPYYxSGjg8JJoHGnNzmycyPRGEdMVzgyl0VyQrToS5 EwoqYI/YBv4+Z/QnYcvuNUcMTPYt9YnrRmPhWJBLGap/La4FQ88dzO1Al8RGTjgwH7eo Mg/F+QMJpZkm7zABuy6FC+sp7eVYJuGaz1mxyfWqOg8SY7p0W8Ms3niAZHXjK5bHToVX y9sT1KwF4tRXCfYO4lSGBmvAZnIZm1H+3a9kOdK9cqYIBotemmxJzSw1Cm8vqo6Cv3x6 /mcwtog33gTqQvhM8ByEJKZtvFyM2UYiCKPwKcQSu6WU69YyWiz/O0HluhACsq5zHf9X GuSw== X-Gm-Message-State: ALyK8tKIlk1hbXcMtFvnw8ix+5G+qaSPJEv35FXsFpXi1HI/sjQdU1OK2grhDHcNRAiKtWFuvpE2xAU5D4dB4w== X-Received: by 10.55.117.71 with SMTP id q68mr3965501qkc.192.1465590832550; Fri, 10 Jun 2016 13:33:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.221.7 with HTTP; Fri, 10 Jun 2016 13:33:52 -0700 (PDT) In-Reply-To: References: From: "H.J. Lu" Date: Fri, 10 Jun 2016 20:33:00 -0000 Message-ID: Subject: Re: [PATCH][x86_64] Convert indirect call via GOT to direct when possible To: Cary Coutant Cc: Sriraman Tallam , binutils , David Li Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00117.txt.bz2 On Fri, Jun 10, 2016 at 1:06 PM, Cary Coutant wrote: > template > static inline bool > can_convert_callq_to_direct(const Symbol* gsym, unsigned int r_type, > size_t r_offset, View_type* view) > { > gold_assert(gsym != NULL); > // We cannot do the conversion unless it's a GOTPCRELX relocation. > if (r_type != elfcpp::R_X86_64_GOTPCRELX) > return false; > // We cannot convert references to IFUNC symbols, or to symbols that > // are not local to the current module. > if (gsym->type() == elfcpp::STT_GNU_IFUNC > || gsym->is_undefined () > || gsym->is_from_dynobj() > || gsym->is_preemptible()) > return false; > // Check for a CALLQ or JMPQ opcode. > return ((*view)[r_offset - 2] == 0xff > && ((*view)[r_offset - 1] == 0x15 > || (*view)[r_offset - 1] == 0x25)); > } > > A couple of observations, though: > > 1. Sri, in your patch, you just test for sym type == STT_FUNC. Isn't > it sufficient to test for sym type != STT_GNU_IFUNC (as in the > convert-to-lea case)? I don't think it really matters -- if we see a > jump to an STT_OBJECT or STT_NOTYPE symbol, why isn't the > transformation just as valid? > > 2. HJ, given an R_X86_64_GOTPCRELX relocation, is it still necessary > to check the opcode during Scan::global()? Doesn't the relocation > guarantee that it's an appropriate instruction for the transformation? > I think in both cases, we could skip fetching the section contents if > we have this relocation. Doesn't gold make different decision based on opcode, like branch vs non-branch? -- H.J.