Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp745409ioo; Thu, 26 May 2022 13:54:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbENawwN7hdHlohOujd4TuY53GwWYWmEcSVjVXMEP+13HUXoJbTeL8kOsq8sruRT6uIiAs X-Received: by 2002:a17:906:1cd5:b0:6ff:5e8:3abb with SMTP id i21-20020a1709061cd500b006ff05e83abbmr13642268ejh.329.1653598484278; Thu, 26 May 2022 13:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653598484; cv=none; d=google.com; s=arc-20160816; b=XMsUI6kpsCIz+BG7fTM5h0RHtQ/FTRyCdJnEgzhIjzwA77CxbUOSOxBfOC465P9MlB wyTyU+dK4+FD6CyCnkqovAjyz+e6UDEfepqSfuzqNlEgNKNAuKCIVae9B2YLIo6v/j/a 19Zogod0zLVnA44iLLQat3G75HkhxOHqpmZeqgObrQTW71MYdLBeuQUkUAu16rsUeYHy SvGyX+40lDkRlhqgaWnqKH1vt+VHUZarH6UpWu4PtVBqZBPUS/ml2ka+ClnflqTbRCmm llFmFaOHX44h5J6hKwwoV652vSm9AEGCZHrp0qIc/yUyqfzoyP/fLtSzs8M7NFyBlZWW FREQ== 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:dkim-filter; bh=MtfOTBQmTIo5gTOtbY0pPCrvlLY0X0Y8Np1AC0lw+eQ=; b=K3G0H7E8WKwp7yCphia4ivlNdJvbY/V04Y84OU6KIpB8uqjxSVMZ3EFB8VwexmM8/r GE0W0CZB5B/RctCxUfTTeA60gJzb2EJmhRVMOaSovEc1jNLEcRHJcjM7kQ0c8GA6NQlq RB3MiZ4+iDUlFRyTKog9iB4VV/zBTd6fIJZAvmnn8EI91yMDbqK7wpQ7FRERf8qXlBtD b0Z/iTWzbSrJKBxykWXSVN1hFG++z9O0FJxJ0nx8snSjv6bWbuKVhn5Hqriyc+uV4O47 jDeGp1Yz2xWmMbbmyWdq/AG464vWe/aRtQhN7UpWpYvSdH7NDJIf87TLAFkKKF7Bh2KV Lp4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ANejoCLa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd15-20020a170907628f00b006febae4977bsi335093ejc.832.2022.05.26.13.54.16; Thu, 26 May 2022 13:54:44 -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=@nifty.com header.s=dec2015msa header.b=ANejoCLa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbiEYKxa (ORCPT + 99 others); Wed, 25 May 2022 06:53:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232603AbiEYKxY (ORCPT ); Wed, 25 May 2022 06:53:24 -0400 Received: from conssluserg-03.nifty.com (conssluserg-03.nifty.com [210.131.2.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2971F9FE1; Wed, 25 May 2022 03:53:19 -0700 (PDT) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 24PAqdlx027069; Wed, 25 May 2022 19:52:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 24PAqdlx027069 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1653475960; bh=MtfOTBQmTIo5gTOtbY0pPCrvlLY0X0Y8Np1AC0lw+eQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ANejoCLa+JDY7f/QB+aEMkxCqqDRpGJEjfMrNqahapNxAEVC0xF1w5CQsnCL2lS2O 1gX3hq/+f+XudCW1fgQzPL47JwdLvbzHvhyX8mJKCHPF2mSwe3Vq0ISv4YiyHKIZIv leBsblGAqcve8Hkc8vS7kamj6WfzeqTIBXvVYMjZHFlpDXO9x9fRxV3FvCfHIzmkm6 6ekMWG561FH5H/cIwmvT1IwvSn3PoF5YGsB2EnjObBC+V2xQ8C9PtYbYqcWCEuUTXe FtvL3ESR85ykxh7vzqD+dtq/iEIgS9wLg2QKTL+7ak7YPZEvhuxVk9D9iBFuLCSERp vapW+WHt4GTdA== X-Nifty-SrcIP: [209.85.216.49] Received: by mail-pj1-f49.google.com with SMTP id ds11so19398988pjb.0; Wed, 25 May 2022 03:52:40 -0700 (PDT) X-Gm-Message-State: AOAM533XlS6M7Y/KNExiIldB1TZ0Puh2rZcT+uYdBc7oV3m5P+cR01IU 4xJaXuVp6XnW4Xlvk2c4vdCWre6LyEo6GiZqjMs= X-Received: by 2002:a17:90a:e004:b0:1e0:7a66:fb3a with SMTP id u4-20020a17090ae00400b001e07a66fb3amr7988416pjy.119.1653475959363; Wed, 25 May 2022 03:52:39 -0700 (PDT) MIME-Version: 1.0 References: <20220513113930.10488-1-masahiroy@kernel.org> <20220513113930.10488-7-masahiroy@kernel.org> <20220525083142.GA1952409@roeck-us.net> In-Reply-To: <20220525083142.GA1952409@roeck-us.net> From: Masahiro Yamada Date: Wed, 25 May 2022 19:51:17 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost To: Guenter Roeck Cc: Linux Kbuild mailing list , Linux Kernel Mailing List , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Peter Zijlstra , linux-modules , clang-built-linux , Ard Biesheuvel , Sami Tolvanen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, May 25, 2022 at 5:31 PM Guenter Roeck wrote: > > On Fri, May 13, 2022 at 08:39:26PM +0900, Masahiro Yamada wrote: > > The 'static' specifier and EXPORT_SYMBOL() are an odd combination. > > > > Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* > > functions") tried to detect it, but this check has false negatives. > > > > Here is the sample code. > > > > Makefile: > > > > obj-y += foo1.o foo2.o > > > > foo1.c: > > > > #include > > static void foo(void) {} > > EXPORT_SYMBOL(foo); > > > > foo2.c: > > > > void foo(void) {} > > > > foo1.c exports the static symbol 'foo', but modpost cannot catch it > > because it is fooled by foo2.c, which has a global symbol with the > > same name. > > > > s->is_static is cleared if a global symbol with the same name is found > > somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily > > belong to the same compilation unit. > > > > This check should be done per compilation unit, but I do not know how > > to do it in modpost. modpost runs against vmlinux.o or modules, which > > merges multiple objects, then forgets their origin. > > > > It is true modpost gets access to the lists of all the member objects > > (.vmlinux.objs and *.mod), but modpost cannot parse individual objects > > because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y. > > > > Add a simple bash script to parse the output from ${NM}. This works for > > CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files. > > > > On parisc builds, this patch results in: > > Building parisc:allnoconfig ... failed > -------------- > Error log: > scripts/check-local-export: sh /opt/buildbot/slave/next-next/build/arch/parisc/nm failed > > Guenter Thanks for the report. parisc overrides NM: NM = sh $(srctree)/arch/parisc/nm I will fix the script to return the correct exit code. -- Best Regards Masahiro Yamada