Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp886735ybv; Thu, 13 Feb 2020 11:21:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzjQFxdOMT5REc8XAM4gy9ZT8REJWdeftGT9qcF/1zuualVPxyy7xFvWtVVekBi/NyDdsAt X-Received: by 2002:a9d:7617:: with SMTP id k23mr7791681otl.329.1581621700918; Thu, 13 Feb 2020 11:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581621700; cv=none; d=google.com; s=arc-20160816; b=wmPYpIp8AuxwSt5FNC3ZKwzRAqYiH22fcg10CPAHjhpWtzCMmD5C4BFUdMCHYNtrZw vG9saHB3AJS99oPivgFDSTkKjlpRLLS4i6cRWL3fhv6D/+SVzQzG4mEQyH1So2o6dLaO GZ6UcPN6ErRCzyNRpOmJMLCKPxmsEUmstfS7Q+E4JPE/C5KcDDUVAuww6VGDDwiIlsTj 8OR/KxSNxQj8Q3ssBynOM5pk5Es69Hws3yKeAxANssBc+O59zLpfe+m2AwjHr1vJ+W+T Z9be1MGvZhFcjrKPEdA/uUOaaecoWZo7X3o1YPsdxMln9Zv3sDq5Yspuq3dmxOQjejZS zLUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tWByifXTfTLSvTHBdOgNdc61Tx0bKdK4+4EitI5eUyQ=; b=u4fogS1/2f2IjBLg8XD45wpl1b/fBQQFBBDNTe6MgJZhxQ9JYfvgMkbLyXB5qJFAxy qSM4CIXCcRFTshPpGu/mDFy63CENeOKoHiNGymbByVj1NkQEsFPxTJavqwYsNarQ1g1j oOalvq+ta63/7iT9Cczbe1+TBMm9MqDNR+Hu+TRmMtM2h8KM19l5oWU0mmFrIbeZJwHg aT4WofQ15Y18xN7S24Yq7RrIwBPQMrsVifv6ViGCcJi0yLPXFxBrk27mkzVmELa95NqR fcHRVBVUJrVlHCoNRxwzuM8bI3ukYb3NaXzjztMuBSVOyK3GkCUSbSU5ruPY/XtsCQpG NhXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="g/GwqTcH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si1589260ote.9.2020.02.13.11.21.25; Thu, 13 Feb 2020 11:21:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="g/GwqTcH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728526AbgBMTU7 (ORCPT + 99 others); Thu, 13 Feb 2020 14:20:59 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45658 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727076AbgBMTU7 (ORCPT ); Thu, 13 Feb 2020 14:20:59 -0500 Received: by mail-pl1-f194.google.com with SMTP id b22so2712705pls.12 for ; Thu, 13 Feb 2020 11:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tWByifXTfTLSvTHBdOgNdc61Tx0bKdK4+4EitI5eUyQ=; b=g/GwqTcHMujuRPSIGkaNZOKKUzu6n0k5JDa+0GvfOcsjntn3041wOpkGKhUTJXN/KS +q29YzqJsGlxpDiPtVLLf8yMg2JyKeda1WCQYLmpksHKD3qONuAeRrpf5ovqFvqL4EMt SmrYagWiQuZ+Qt1Rkfp3tmKOYLgVftLiXmYms7G5UF6QzhlW9kQI9zKnGx9APrFfgS3e SkuW2HXzPOctNP5sX+crPK6Deo0ziia5TyqH+0DFOMeaZt++uJyTDro6Q4LvELSMjd5f CuHYMyw2bE6530kJU1TaSw8DshOvrrc2ikC60zVKlCFchLZQSSUw4t3QY4vwdfrZFxmv eOdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tWByifXTfTLSvTHBdOgNdc61Tx0bKdK4+4EitI5eUyQ=; b=lVKcRP1u+semaEKwcG9m1fHcJ/iCiS1AD1KteBlSY26AsS3BcDGGC0ihG1dkmvB2cM BIgtRHvTQ51CkjFdSc9KxXEYNC4iVmnWrlHF392UEz7S5wWYy01OMIecgMVv54mZx54k DQLxxEKSFWz6BCfiK/1DpyRCeq6KYY8PX67/OnvIcZIt69PjnYWMejdiiSC5lMfqSudT Dau/PkFbPIhXUsF/7rNxbkHyJ2NoVC7b+sq3ChJ1200ZICzHcmOWMiRbDrKOU09HXl7L GBYS0ViK3Na9lDlWHAarL/yxnvNmBEnIHJ6xtxaXUMQaV/eVf7dkXHKfIf+14DnnxtrS ah5w== X-Gm-Message-State: APjAAAXG8ol3gArJZwOrZxIjzzBPlkYpI7tKeIwh9aeTREhGKnaHN9hp g19J+KOkuMuP+YM5zfZ+9qtaew== X-Received: by 2002:a17:90a:2545:: with SMTP id j63mr7048904pje.128.1581621658693; Thu, 13 Feb 2020 11:20:58 -0800 (PST) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id l37sm3331916pjb.15.2020.02.13.11.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 11:20:58 -0800 (PST) Date: Thu, 13 Feb 2020 11:20:55 -0800 From: Fangrui Song To: Nick Desaulniers Cc: jpoimboe@redhat.com, peterz@infradead.org, clang-built-linux@googlegroups.com, Nathan Chancellor , linux-kernel@vger.kernel.org Subject: Re: [PATCH] objtool: ignore .L prefixed local symbols Message-ID: <20200213192055.23kn5pp3s6gwxamq@google.com> References: <20200213184708.205083-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200213184708.205083-1-ndesaulniers@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-02-13, Nick Desaulniers wrote: >Top of tree LLVM has optimizations related to >-fno-semantic-interposition to avoid emitting PLT relocations for >references to symbols located in the same translation unit, where it >will emit "local symbol" references. > >Clang builds fall back on GNU as for assembling, currently. It appears a >bug in GNU as introduced around 2.31 is keeping around local labels in >the symbol table, despite the documentation saying: > >"Local symbols are defined and used within the assembler, but they are >normally not saved in object files." If you can reword the paragraph above mentioning the fact below without being more verbose, please do that. If the reference is within the same section which defines the .L symbol, there is no outstanding relocation. If the reference is outside the section, there will be an R_X86_64_PLT32 referencing .L >When objtool searches for a symbol at a given offset, it's finding the >incorrectly kept .L$local symbol that should have been discarded >by the assembler. > >A patch for GNU as has been authored. For now, objtool should not treat >local symbols as the expected symbol for a given offset when iterating >the symbol table. Agree. binutils 2.31~2.34 will be affected. objtool has to work around the existing releases. >commit 644592d32837 ("objtool: Fail the kernel build on fatal errors") >exposed this issue. > >Link: https://github.com/ClangBuiltLinux/linux/issues/872 >Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-Names >Link: https://sourceware.org/ml/binutils/2020-02/msg00243.html >Link: https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/286292010 >Debugged-by: Nathan Chancellor >Debugged-by: Fangrui Song >Suggested-by: Josh Poimboeuf >Signed-off-by: Nick Desaulniers >--- >Build tested allyesconfig with ToT Clang and GCC 9.2.1. >Boot tested defconfig with ToT Clang and GCC 9.2.1. > > tools/objtool/elf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c >index edba4745f25a..9c1e3cc928b0 100644 >--- a/tools/objtool/elf.c >+++ b/tools/objtool/elf.c >@@ -63,7 +63,8 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) > > list_for_each_entry(sym, &sec->symbol_list, list) > if (sym->type != STT_SECTION && >- sym->offset == offset) >+ sym->offset == offset && >+ strstr(sym->name, ".L") != sym->name) !strncmp(sym->name, ".L", 2) .L in the middle of a symbol name may be rare, though. > return sym; > > return NULL; >-- >2.25.0.225.g125e21ebc7-goog >