Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp461399pxb; Wed, 20 Jan 2021 11:12:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2DF6qeKSFaGXmm61ZCAj/M8cnp/9uhn+9My8TnvGAT4DJ6bMcBuig70PbcAJB1cRUNAbe X-Received: by 2002:a05:6402:757:: with SMTP id p23mr8609879edy.245.1611169975068; Wed, 20 Jan 2021 11:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611169975; cv=none; d=google.com; s=arc-20160816; b=XuUWUtf/ihhULlZ9R9DuZLlWk5wqmCSTr6iXecaTJvTlfBJaeOAVrc08khXyfo2oZv 8ZKUdCb5OidWYNyVDvSJS+xz2MWtUcSk2QgyPL5jvSGOsw/EX//vOdeo0Tyb316NaoNN HJ9a6l4r5xHawDfJ0OmYqaePZt3PkKbe7u+GgWd/uXVRrRY3lSi6mDk5mNRKP9Ur+3RP JR/mGvoTqmZzz68RylCblUJ2F8250nCzyXscDgiB5Bl3itVqODd1uLlUMj548s5G/5sI KDjWScwKUlPQk70sOXgU6qihJjpwG2JqN0wX46YuzEASdIAXpxkfBCY+5AJAphP4KkrU hdGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2IjT5vM0wwpC9kpod4C2W/rvy6n2du1gFGDH7SeVYpA=; b=e3EJbGpewT76mjalSwmSlnBHWhqiBFgXvodgr3OJGRTmEpziNLxQoQm7h9x4fW03uJ BQ6caK2CVHrj09w++DZDcUpUqg8f4JhAvq8h3WdNy50odZptR6+xB3PZfOHtaE9OT8wZ jwZad1kIIaRJ4RNjK9KqaLH/2WZmkYP24sJYuoIUhzpEFW7/sPe5nBi0Mbg57g5t6jPf l+nuYsF0fH7MF730JvcCY/8igIz2FFoJOjf5a0ipR1G0Uc0Q0at3mMs/2ptonA36J2XI 5FgEh3yqH6qMa+CL2t++ZUO/+qLKWuDQWPr/5UvDPtGHpz1YF9zt8P/hcmkKfOudvNfP 1Utg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FnEQe4Nd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n2si1175078edi.136.2021.01.20.11.12.30; Wed, 20 Jan 2021 11:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FnEQe4Nd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2392253AbhATTHU (ORCPT + 99 others); Wed, 20 Jan 2021 14:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387437AbhATS5y (ORCPT ); Wed, 20 Jan 2021 13:57:54 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9458FC061757 for ; Wed, 20 Jan 2021 10:57:14 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id 31so669534plb.10 for ; Wed, 20 Jan 2021 10:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2IjT5vM0wwpC9kpod4C2W/rvy6n2du1gFGDH7SeVYpA=; b=FnEQe4NdFtLMCzMpWBm01f0nkqCIXmpGnyv1Isu2e3YosASvuZSZMrYjbK4n8SXMKA 11bXc0VkJx6niIVERe7ZEenE3e3K51Vv3ClAmmpkWCIHiy5yqtGOEHMojs46e1tudcx4 +KIkD1vhoSe630IfWDZSi2/JMI5WF+PLk6lbpa61juWxsWRAprfL7r48gLTGHQakJ7YD GpY7BfvBRZOrAG4SP79XUJjH/qy1fxHu/YqL/qQLu+kUC2UJ8z64e5jwz8JI222O5pAf 5k8r0BQXnUgeTXrba1KWIDUD6WLARPQD57kBKzC5P3LoMyPDpd4Tn0qooee6liLjXLjl GwHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2IjT5vM0wwpC9kpod4C2W/rvy6n2du1gFGDH7SeVYpA=; b=qqI4ZLEVOIzSg+2i2PbcMmyDyfkUWTlY6RCumVK/+0wiUt4A0z9LZ2XoYZaHaLcAoX sNJra89cWgvLhoZW1DwwQ5t4WLZnV2wVMyhnIFeWtpKlz8pRYeVIaTTOsVwT7CQgC/YL 7wbge/E6xJasYI4paQacUIFoJr3JxUP7KrqSz0gBdLxCuqJRYGsh7O1ZVFPkaN9ZbrLu MmOud0H1Cua/Ko0V13vngdEiYAgF1UpMVv2vlf5FFlobrOJOf6AE9SwXFtDxNf88HEZj i8QCm7m2GwRONECkABpy/Qk8zM4Jc39MfRuGD+zzzbGKA883C6WxnVIKKWSrcMCmm6c/ 4sOw== X-Gm-Message-State: AOAM532Em94NqCH9+fwJShuhXRT8/ACL1CBnilvnKLyIWO+b8cuR5mTb WloU/DXHRwayevhX5GhsUS3Q4DSSQfmlq1yRSQc1wg== X-Received: by 2002:a17:90b:228f:: with SMTP id kx15mr733291pjb.32.1611169033913; Wed, 20 Jan 2021 10:57:13 -0800 (PST) MIME-Version: 1.0 References: <20210120072547.10221-1-yashsri421@gmail.com> <14707ab9-1872-4f8c-3ed8-e77b663c3adb@gmail.com> In-Reply-To: From: Nick Desaulniers Date: Wed, 20 Jan 2021 10:57:03 -0800 Message-ID: Subject: Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files To: Josh Poimboeuf Cc: Aditya , LKML , Lukas Bulwahn , dwaipayanray1@gmail.com, Mark Brown , linux-kernel-mentees@lists.linuxfoundation.org, clang-built-linux , Joe Perches Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 10:43 AM Joe Perches wrote: > > On Wed, 2021-01-20 at 18:23 +0530, Aditya wrote: > > On 20/1/21 2:51 pm, Joe Perches wrote: > > > On Wed, 2021-01-20 at 12:55 +0530, Aditya Srivastava wrote: > > > > Local symbols prefixed with '.L' do not emit symbol table entries, as > > > > they have special meaning for the assembler. > > > > > > > > '.L' prefixed symbols can be used within a code region, but should be > > > > avoided for denoting a range of code via 'SYM_*_START/END' annotations. > > > > > > > > Add a new check to emit a warning on finding the usage of '.L' symbols > > > > in '.S' files, if it lies within SYM_*_START/END annotation pair. > > > > > > I believe this needs a test for $file as it won't work well on > > > patches as the SYM_*_START/END may not be in the patch context. > > > > > Okay. > > > > > Also, is this supposed to work for local labels like '.L:'? > > > I don't think a warning should be generated for those. > > > > > Yes, currently it will generate warning for all symbols which start > > with .L and have non- white character symbol following it, if it is > > lying within SYM_*_START/END annotation pair. > > > > Should I reduce the check to \.L_\S+ instead? (please note "_" > > following ".L") > > Use grep first. That would still match several existing labels. > > > Pardon me, I'm not good with assembly :/ > > Spending time reading docs can help with that. > > Mark? Can you please comment about the below? > > I believe the test should be: > > if ($realfile =~ /\.S$/ && > $line =~ /^\+\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) { > WARN(...); > } > > so that only this code currently matches: > > $ git grep -P '^\s*SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L' -- '*.S' > arch/x86/boot/compressed/head_32.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) > arch/x86/boot/compressed/head_32.S:SYM_FUNC_END(.Lrelocated) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lrelocated) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lpaging_enabled) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lpaging_enabled) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lno_longmode) > arch/x86/boot/compressed/head_64.S:SYM_FUNC_END(.Lno_longmode) > arch/x86/boot/pmjump.S:SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32) > arch/x86/boot/pmjump.S:SYM_FUNC_END(.Lin_pm32) > arch/x86/entry/entry_64.S:SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) > arch/x86/entry/entry_64.S:SYM_CODE_END(.Lbad_gs) > arch/x86/lib/copy_user_64.S:SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail) > arch/x86/lib/copy_user_64.S:SYM_CODE_END(.Lcopy_user_handle_tail) > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_clac) > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_clac) > arch/x86/lib/getuser.S:SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac) > arch/x86/lib/getuser.S:SYM_CODE_END(.Lbad_get_user_8_clac) > arch/x86/lib/putuser.S:SYM_CODE_START_LOCAL(.Lbad_put_user_clac) > arch/x86/lib/putuser.S:SYM_CODE_END(.Lbad_put_user_clac) > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_START_LOCAL(.Lwakeup_idt) > arch/x86/realmode/rm/wakeup_asm.S:SYM_DATA_END(.Lwakeup_idt) Josh, I assume objtool does not annotate code under: arch/x86/boot/ arch/x86/entry/ arch/x86/realmode/ ? The rest, ie arch/x86/lib/ seem potentially relevant? -- Thanks, ~Nick Desaulniers