Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp273328pxb; Wed, 20 Apr 2022 22:25:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrVybCYYd5E6AH+I8HdeRwkN+GDClnQ3CdBSOkUlnlTatCGdKXQuAiTNwdmb7tzyEvTTjG X-Received: by 2002:a17:907:3ea5:b0:6f0:1069:c25c with SMTP id hs37-20020a1709073ea500b006f01069c25cmr3552726ejc.337.1650518752878; Wed, 20 Apr 2022 22:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650518752; cv=none; d=google.com; s=arc-20160816; b=YY3hLzV7EMmH7hPJIRvHDQyO8KZaLl68Dnswnwxhkt17XNqTIcOYs6LQaR1EI8LSPT QQd+1C06D9FRVCen85sAuVxr9ZB/X27DF5dSMGXBur1YKsSLNh305B3BsgOUa4uevZjL CtcDn5tAbHtQxju22Y7Ib2chsSV46U32B++pLc3XTdQQGN8Hi3PEgTCP0hN51kMccwOX dbpy/mDjd0Ipp2tPXFt9TQ9REVDqb3M0WrjLWrZDwrXHkVRYDPENi0tGKQHe4SJM6kjK gAiHXhUniWTJyYod+cDrW1mfBc1+QZLZ6CkThknOv6BvhRStgQzZL+kI5nSCGcGKcUzI o8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jvOFqMFAlj4tb7RNdnHBLTW8NkLhW9U0AcHSUvRhDGQ=; b=tFq2kZj2/4wZdsJCBSfu+/0I7iKv9zuuktoclbXPoL5J46PL5IeXerFUPdwHhPWOoY zNh6f7Rth8zwKmIEQFzgUsSOvrii4Y5dkcC3AVN5Kc6cRcUoMVVolaed1U4VTEUcSKgr DWSDqCLSJO9NtoVl6YIicVaIJzyQiyU47hpT6Y4HPIoetOPcZtwkEiZGFFZoHxmnKuQQ xqFomQyw2vLx+H9tBMsw6AuRkOU2Rdq9ht8DmFsRngwVhstmxFh3WiUstKKaU0WlaJDV x3aauuyA4nOHf1Fb7Ov98p9D0T9JTLsTSus/fmdra38rtUrvicbjHEG9IJ8kdUvitk59 cZkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=aoIubLIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz8-20020a170906f2c800b006e840b55d9asi3495886ejb.402.2022.04.20.22.25.28; Wed, 20 Apr 2022 22:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=aoIubLIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346105AbiDSURt (ORCPT + 99 others); Tue, 19 Apr 2022 16:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351891AbiDSURc (ORCPT ); Tue, 19 Apr 2022 16:17:32 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A0D2A6 for ; Tue, 19 Apr 2022 13:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jvOFqMFAlj4tb7RNdnHBLTW8NkLhW9U0AcHSUvRhDGQ=; b=aoIubLIauB+2yUS1p6X7DsG1oH qjNi4484kyQhPO6+MzhLgcXTrJnz79St6EzEj1+SrRf28zcqL2n+IwnAYiVedFuOiyi5wi6vLCM3J 9pN58YR92eq9OkYO3KIPj1QMYEjktfqKiNw41OaR+28mdCnowvoDog31aJaT2ndYZGJ6rNHIFdRKw 4ym/alg0zdLJn/Xr9RHy9Si+h0rrMK/aTzW7NGbMCaEYdWfsvk0z6hp2NmTkrx/h+zQSI0rZKPw3Q n7G6sbkKf9QwOQAvIA8mDGD5ibNOAnQi/TBzzsGU/E35tpyMFD3+LriLtt7QK3BF4RLqoQetbK0vu O1EZ7dSg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nguFC-006uYU-A5; Tue, 19 Apr 2022 20:14:39 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id E65ED9861A4; Tue, 19 Apr 2022 22:14:35 +0200 (CEST) Date: Tue, 19 Apr 2022 22:14:35 +0200 From: Peter Zijlstra To: Borislav Petkov Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, x86@kernel.org, Miroslav Benes Subject: Re: [PATCH v2] scripts: Create objdump-func helper script Message-ID: <20220419201435.GY2731@worktop.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 19, 2022 at 09:50:01PM +0200, Borislav Petkov wrote: > On Tue, Apr 19, 2022 at 09:12:23AM -0700, Josh Poimboeuf wrote: > > Add a simple script which disassembles a single function from an object > > file. Comes in handy for objtool warnings and kernel stack traces. > > > > Originally-by: Peter Zijlstra > > Signed-off-by: Josh Poimboeuf > > --- > > v2: > > - require gawk > > > > scripts/objdump-func | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > create mode 100755 scripts/objdump-func > > Was that supposed to be user-friendly too? > > $ ./scripts/objdump-func -h > ./scripts/objdump-func: line 16: $1: unbound variable > > :-) > > > It works tho: > > $ ./scripts/objdump-func vmlinux rewind_stack_and_make_dead > 0000 ffffffff81001c00 : > 0000 ffffffff81001c00: 31 ed xor %ebp,%ebp > 0000 ffffffff81001c02: 65 48 8b 04 25 d0 ec 01 00 mov %gs:0x1ecd0,%rax > 0000 ffffffff81001c0b: 48 8d a0 58 ff ff ff lea -0xa8(%rax),%rsp > 0000 ffffffff81001c12: e8 39 24 07 00 call ffffffff81074050 > ^^^^ > > I guess those zeros at the beginning are supposed to mean something... Use the .o file and it'll work: $ ./objdump-func.sh defconfig-build/vmlinux.o rewind_stack_and_make_dead 0000 0000000000001380 : 0000 1380: 31 ed xor %ebp,%ebp 0002 1382: 65 48 8b 04 25 00 00 00 00 mov %gs:0x0,%rax 1387: R_X86_64_32S cpu_current_top_of_stack 000b 138b: 48 8d a0 58 ff ff ff lea -0xa8(%rax),%rsp 0012 1392: e8 00 00 00 00 call 1397 1393: R_X86_64_PLT32 make_task_dead-0x4 Now the first coloumn is the symbol relative offset, while the second column is the section relative offset objdump normally gives you.