Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3506264ioo; Wed, 25 May 2022 02:04:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQVZKmPbXocTAtRHpa0cPS8g48dG6MTE02m2UvUCnJY+OpyEc/hlTQQXYAwl9wF2A7Oarz X-Received: by 2002:a17:907:7f2a:b0:6fe:cedd:df22 with SMTP id qf42-20020a1709077f2a00b006fecedddf22mr15136231ejc.298.1653469451260; Wed, 25 May 2022 02:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653469451; cv=none; d=google.com; s=arc-20160816; b=TTtYGehViYzgMJC3YZ1zYLqEoDR8wR0ZJuoLlvXyZRcHzcoA79nEOqZswzaVCrKqwk aaNhqeqR1vEF2S/lphDMCCkXEdi2wNqAIWT5CXWSRJS1gjTDMlKOg4NZPMkipjjOxzfF DLM/o0yDkwdtC/u1OSTV8Rac3IKkEVDeZsVtGzXBuldOshM1ZOUa23pqWt5Ne+oe1Hu+ i2dOwTnXrus66SZiQUaeFi82Q+rLcD9Pj0G3//zn5MvvWqIl5yOeqoDRywDZwmRmDdDd FbIvLk3tfnbF7jSHY38KqbEWycr/ZID8FW4rKruZ7HeZ2s5yLTfQI3BYJLEI/Vw7cZPD JZ4Q== 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:sender:dkim-signature; bh=+YhgW7NAnERndezG/DaemCXMRg733gpPkur4BTgIaQw=; b=jVeWUGe6jOKoasRH78iA8DUL5oZhutHF9KQ+gHelRiiAHKSVy39XeEFyD5MfaRnIoa qQq4AUxnIVqSMzdcNUzleJGdrga/1HXEv1W73StCnFm5ro2gPveir1m1WxWtAQU7Ynm/ Cnm50+bOmhoIsSyG4u31tZT2FSbsJDHie9n1jlZgAjMG2WQesjU9a0XNpF5V2tzaLyil BthQncR2fWgwVsWZVUHKOvSNiJOs2m66EzEDagDNnesnFp9NdONyHXM3is6ZJB3yGtGo Tf1rs9jnx9CcNbAKz32ay2x3E2dYOiKA2KGyAYPN+cFRMBmqn8tzvrEP9Rzan5yWgvHt zf6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IuHTNa+I; 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 gn38-20020a1709070d2600b006ff165f19e6si594525ejc.350.2022.05.25.02.03.43; Wed, 25 May 2022 02:04:11 -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=@gmail.com header.s=20210112 header.b=IuHTNa+I; 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 S233046AbiEYIcB (ORCPT + 99 others); Wed, 25 May 2022 04:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232037AbiEYIbr (ORCPT ); Wed, 25 May 2022 04:31:47 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C22C39; Wed, 25 May 2022 01:31:44 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-f2c296d320so1010203fac.8; Wed, 25 May 2022 01:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+YhgW7NAnERndezG/DaemCXMRg733gpPkur4BTgIaQw=; b=IuHTNa+IXAL6LEL2YyMB482iZtMh0+jmuW8i6AL7X/UkTx3yI9MdMXZ2u42WpedIx+ Ut4PzMpqdWrHa7YgBJ9GR0D07qh65VLonZwsByiXfoSD/X1tFr7x3HZ+l9Q2JCWC/Kic 8Y1VytjiBHSx2uz78Q9FatEcNiPyZ9OHREAgAqCcOmguatMXdh5REZcYMQrFTIjRtD40 AtjTc95Epz41aD3RKBR+ydNRSgjZttSLLOv/PVsBBagWjLdJ8LaCi4/7AEAoQbq/5zgU +CQLASpfnpdIxA0y0HZ7mknsRGStXGke037bgzb3l8FStbN0MZ3ncLwP3fHwVcSePrRD qZIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=+YhgW7NAnERndezG/DaemCXMRg733gpPkur4BTgIaQw=; b=5Kecmb9fA1h64jsjZd4W9CNVL6jScFT5IAgKL7B6jOtQY4i8UffdDKo01U6rHf0QeQ MAA7MzerJAVyh5NpqduBnwivEwLoV7lc86sUTYlAKJW9jREm4Zx6zQi//95U38vD+p2f aGWfiK05OXVlUClr14Qm/dDCX7+E115YV7lPip2EN0ypufzkgk3hvt7PoOJtG/Sfh3iF yAfeCq8iSFQy4GHtwi3fif6gpYSuPSUkNoS5Zk8jEYo6iZyE7J+a/LsRqBoEs0Dh9ZfR u9JeRp508Ay10Audq9vgSFXgN3VWQqyzt8kXokr/bvyCLz0pv6FhqOHfSAvA6q/H0Hiy yicQ== X-Gm-Message-State: AOAM533CuwHTxvFovwByBdx+dwTYx+vMetGpM36Sh4gJhEHyoeGug0OK nPGnS+ts37zXDLuePyx0Oio= X-Received: by 2002:a05:6870:c207:b0:f1:85cd:648f with SMTP id z7-20020a056870c20700b000f185cd648fmr4747352oae.103.1653467504296; Wed, 25 May 2022 01:31:44 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k1-20020a056870a4c100b000f28d8f2debsm2114774oal.2.2022.05.25.01.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 01:31:43 -0700 (PDT) Sender: Guenter Roeck Date: Wed, 25 May 2022 01:31:42 -0700 From: Guenter Roeck To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Peter Zijlstra , linux-modules@vger.kernel.org, llvm@lists.linux.dev, Ard Biesheuvel , Sami Tolvanen Subject: Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script instead of modpost Message-ID: <20220525083142.GA1952409@roeck-us.net> References: <20220513113930.10488-1-masahiroy@kernel.org> <20220513113930.10488-7-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220513113930.10488-7-masahiroy@kernel.org> X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 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