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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 B18B1C433DB for ; Wed, 20 Jan 2021 19:56:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DFB42343E for ; Wed, 20 Jan 2021 19:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392670AbhATTzs (ORCPT ); Wed, 20 Jan 2021 14:55:48 -0500 Received: from smtprelay0125.hostedemail.com ([216.40.44.125]:52892 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387509AbhATSoJ (ORCPT ); Wed, 20 Jan 2021 13:44:09 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id CB1C1365F; Wed, 20 Jan 2021 18:43:24 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: lunch37_0515e5b2755c X-Filterd-Recvd-Size: 4179 Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf20.hostedemail.com (Postfix) with ESMTPA; Wed, 20 Jan 2021 18:43:23 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: add warning for avoiding .L prefix symbols in assembly files From: Joe Perches To: Aditya , linux-kernel@vger.kernel.org Cc: lukas.bulwahn@gmail.com, dwaipayanray1@gmail.com, broonie@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, clang-built-linux@googlegroups.com Date: Wed, 20 Jan 2021 10:43:22 -0800 In-Reply-To: <14707ab9-1872-4f8c-3ed8-e77b663c3adb@gmail.com> References: <20210120072547.10221-1-yashsri421@gmail.com> <14707ab9-1872-4f8c-3ed8-e77b663c3adb@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)