From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD587C388F7 for ; Tue, 10 Nov 2020 16:13:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21E48206E3 for ; Tue, 10 Nov 2020 16:13:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iRwMR3iF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IO4LgfFx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21E48206E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=T9UravMqbx45DjgZwbXFUShGm5Rcsvsfiv49Tn24EmU=; b=iRwMR3iFzKrwYrD5qrM+VHvpy RFCxAwStjKwLI0/IRuY2fEG6n6/Gj/1pgyyP5MkKH3P6350VPJiSPGAuDSUBMUl+saMxXTGnEqyvJ qMHPsOKO8miu0H39hqKUjBB+P5gjaVmD/VMPRcM1AQDe2nbzDa6l0fF8QQAbQowDUPhJjqqAmO2YU XG3PTZOYZYb7bkqn4XawBsM2nJpN0KYURn6Ka1Il8ly/8+cklAMC2JrXFOIHCZI67MvisncMvguUI fUSTrTaXE1WCKBG9Uo4obp18E+BXuIfG5m1nThYu94jtq/Rib9eS8IahQkrhF4mrEih5I6URDmM/U OfauE9tsQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcWFL-0004J6-3J; Tue, 10 Nov 2020 16:11:51 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcWFH-0004Hf-UI for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 16:11:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605024707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Jp+HmPlYtR2IGGTGzYIzvrsfgydKFOm7mlacIEpnzOM=; b=IO4LgfFxqGUYzF9rgsuV4gXHby03P1gh83i93QQmZ1XeucXk1YopCA6n4UaRtlCOk2OI1+ bF7mmbPGPhgZNBHOTVRdwVhc3gjLljgH3D2gxPD9ghE0a5H4xnnMAd5yEz1qKJpH77xJ8P tb3lWSl3xji14Q8EMACfbB970nOlPZk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-5kzcWzDFO8i3LtgKf7nZng-1; Tue, 10 Nov 2020 11:11:43 -0500 X-MC-Unique: 5kzcWzDFO8i3LtgKf7nZng-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48EDA1084D61; Tue, 10 Nov 2020 16:11:40 +0000 (UTC) Received: from treble (ovpn-120-104.rdu2.redhat.com [10.10.120.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDA1C5C1D0; Tue, 10 Nov 2020 16:11:30 +0000 (UTC) Date: Tue, 10 Nov 2020 10:11:24 -0600 From: Josh Poimboeuf To: Sami Tolvanen Subject: Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps Message-ID: <20201110161124.lztfgffqh2qrlwwv@treble> References: <20201015203942.f3kwcohcwwa6lagd@treble> <20201020185217.ilg6w5l7ujau2246@treble> <20201021085606.GZ2628@hirez.programming.kicks-ass.net> <20201023173617.GA3021099@google.com> <20201110022924.tekltjo25wtrao7z@treble> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_111148_046339_A7A71372 X-CRM114-Status: GOOD ( 24.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , Kees Cook , "Paul E. McKenney" , Jann Horn , Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , the arch/x86 maintainers , Nick Desaulniers , kernel list , Steven Rostedt , linux-kbuild , clang-built-linux , linux-pci@vger.kernel.org, Kernel Hardening , Will Deacon , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 09, 2020 at 08:48:01PM -0800, Sami Tolvanen wrote: > On Mon, Nov 9, 2020 at 6:29 PM Josh Poimboeuf wrote: > > How would I recreate all these warnings? > > You can reproduce all of these using a normal gcc build without any of > the LTO patches by running objtool check -arfld vmlinux.o. However, > with gcc you'll see even more warnings due to duplicate symbol names, > as Peter pointed out elsewhere in the thread, so I looked at only the > warnings that objtool also prints with LTO. > > Note that the LTO series contains a patch to split noinstr validation > from --vmlinux, as we need to run objtool here even if > CONFIG_VMLINUX_VALIDATION isn't selected, so I have not looked at the > noinstr warnings. The latest LTO tree is available here: > > https://github.com/samitolvanen/linux/commits/clang-lto > > > Here's the patch for hopefully making the warnings more helpful: > > Thanks, I'll give it a try. Here's the version without the nonsensical debug warning :-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4e1d7460574b..ced7e4754cba 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -217,6 +217,21 @@ struct symbol *find_func_containing(struct section *sec, unsigned long offset) return NULL; } +struct symbol *find_symbol_preceding(struct section *sec, unsigned long offset) +{ + struct symbol *sym; + + /* + * This is slow, but used for warning messages. + */ + while (1) { + sym = find_symbol_by_offset(sec, offset); + if (sym || !offset) + return sym; + offset--; + } +} + struct symbol *find_symbol_by_name(const struct elf *elf, const char *name) { struct symbol *sym; diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h index 807f8c670097..841902ed381e 100644 --- a/tools/objtool/elf.h +++ b/tools/objtool/elf.h @@ -136,10 +136,11 @@ struct symbol *find_func_by_offset(struct section *sec, unsigned long offset); struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset); struct symbol *find_symbol_by_name(const struct elf *elf, const char *name); struct symbol *find_symbol_containing(const struct section *sec, unsigned long offset); +struct symbol *find_func_containing(struct section *sec, unsigned long offset); +struct symbol *find_symbol_preceding(struct section *sec, unsigned long offset); struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset); struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, unsigned long offset, unsigned int len); -struct symbol *find_func_containing(struct section *sec, unsigned long offset); int elf_rebuild_reloc_section(struct elf *elf, struct section *sec); #define for_each_sec(file, sec) \ diff --git a/tools/objtool/warn.h b/tools/objtool/warn.h index 7799f60de80a..33da0f2ed9d5 100644 --- a/tools/objtool/warn.h +++ b/tools/objtool/warn.h @@ -22,6 +22,8 @@ static inline char *offstr(struct section *sec, unsigned long offset) unsigned long name_off; func = find_func_containing(sec, offset); + if (!func) + func = find_symbol_preceding(sec, offset); if (func) { name = func->name; name_off = offset - func->offset; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel