From patchwork Fri Jul 21 15:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 13322141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E52D6C001DC for ; Fri, 21 Jul 2023 15:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Cc:MIME-Version:Message-ID:Date :Subject:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=cxWNuCD/FY9+bOH+xH/zSkOnDDjXyGjk8BRTlhtO7ik=; b=QZDWxnXpD/u7Vc MexwchhYnRzYOozUiSERPmW3qRFozSwbs2nqg/eAM+5q8BL1Qr++XEzYOZPN4p5OXVier50Qn0P65 i0OauswiCgl8aBTe/aig5DIoMDX9edyB7+QD2GGknLUtB2YDROeCyztdnCChJZK0qsaXvWeuoLmxo AvvTeX2qFouNu7heOpxWLaAcMoloB+30L/+lLDX3Nvy8MXJCy9+GniLeYS/ORqdFf1RB2yIYr2T8v rjBIlaEpbVGG+wSOQ/C8ANFudkJDnI/d114QmOAQG4xpWXzu58hF1IHfrvFwz8IqutaXcH7rSBnpK vLwN8246CyKbnSeqHg4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMrvO-00EPyr-26; Fri, 21 Jul 2023 15:20:10 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMrvK-00EPwj-0g for linux-riscv@lists.infradead.org; Fri, 21 Jul 2023 15:20:08 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-262ea2ff59dso1036801a91.0 for ; Fri, 21 Jul 2023 08:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689952802; x=1690557602; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:from:to:cc:subject:date:message-id:reply-to; bh=FGQb7KpZNRpkho8cgTr8i+WhDErsFNhD07P94FZeYEg=; b=jyGW0VROISNel3ta/haidB7fgiMqP0Zkmj+6DUV0U7xOMbyjTGO4zqz+UmikA0arDq G1XP4wsJy/uW/lCh6p+t3AF2zpxi3bX5eIP5MvGsGL/s6wIpcIQFKGkDcCKmE5bAc7XX 2I7Lc7jgkq9tCmnpQapaKNEPFPpvKnZsZ1VTaMmoLQMuQUwcnXFFUuBwS9EE27hi1V/K x7X6eSi01HV7s3y4QlE43UmyszzSF9coNM4P2xz91MRaQXyJzKS52FqI/z7s7qKvuffo 1F2GDRay3xUjIDDDh+e079CtbD/2llPbTo/blF3uIunNuI5jYSlvNDLuFfyC4bJiA9nI Hc0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689952802; x=1690557602; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FGQb7KpZNRpkho8cgTr8i+WhDErsFNhD07P94FZeYEg=; b=Hj7CCs49llQc7Yttb+wf5ddUkGFisEdxIvlqyP0JJ8QwxgvBel/2HUdqUB91vtnswu MxZ80HYCDqb/qDD6Vly1u8ZDxUK2pbNvt4i8k7R6J+3Uy+I3DdDFGdfmpzozyJZuraS9 VbZvPUGAnzTyo/Juk/avlK7kLgDk5zJbGW1z2pDRXocEU0lfW50GuizbmyBHXNk3BEf4 v/qZjvsJjQL/x2F/vHw5eKARdb5bHeKKp3LMlUv4EfZS0KPdZGHD868a/mXbqW7sdFGf gXYuw0NAuuktQiDEMi9aM51YSuyK7aNuKGoNqwnK6Ubc6x7eiu6QZ5wDUSEVfU6Xj/cQ urwg== X-Gm-Message-State: ABy/qLYOuQstYV1T6wwoIciZycXQ0MBkA1qJmDQlB0wJ6zAVYqmDEF+S 3ZC/G5kW9S8PnpRjDYD/QcnDRw7ABGlsDbRZApk= X-Google-Smtp-Source: APBJJlG6GgiEc98hunrP1hfoR2yOoKJPDjPA4NwGb4Tj9nP0mHHeF6RAEjvKUb7PpLJBrmKu+6FLog== X-Received: by 2002:a17:90a:7c0f:b0:262:c212:9898 with SMTP id v15-20020a17090a7c0f00b00262c2129898mr1515120pjf.26.1689952802429; Fri, 21 Jul 2023 08:20:02 -0700 (PDT) Received: from localhost ([135.180.227.0]) by smtp.gmail.com with ESMTPSA id g13-20020a17090a290d00b0025eb5aafd3csm2830783pjd.32.2023.07.21.08.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 08:20:01 -0700 (PDT) Subject: [PATCH] modpost, kallsyms: Treat add '$'-prefixed symbols as mapping symbols Date: Fri, 21 Jul 2023 08:01:48 -0700 Message-ID: <20230721150147.11720-2-palmer@rivosinc.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Palmer Dabbelt From: Palmer Dabbelt To: masahiroy@kernel.org, wangkefeng.wang@huawei.com, mcgrof@kernel.org, nathan@kernel.org, ndesaulniers@google.com, nicolas@fjasle.eu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230721_082006_467504_8BCAC332 X-CRM114-Status: GOOD ( 16.86 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Trying to restrict the '$'-prefix change to RISC-V caused some fallout, so let's just treat all those symbols as special. Fixes: c05780ef3c1 ("module: Ignore RISC-V mapping symbols too") Link: https://lore.kernel.org/all/20230712015747.77263-1-wangkefeng.wang@huawei.com/ Signed-off-by: Palmer Dabbelt Reviewed-by: Masahiro Yamada --- It wasn't clear if we should just revert the original patch and spin a new one, but looks like this is in at least some trees so I sent a follow-on patch -- at least this way I can make coffee before forgetting to send it ;) --- include/linux/module_symbol.h | 16 ++-------------- kernel/module/kallsyms.c | 2 +- scripts/mod/modpost.c | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h index 5b799942b243..1269543d0634 100644 --- a/include/linux/module_symbol.h +++ b/include/linux/module_symbol.h @@ -3,25 +3,13 @@ #define _LINUX_MODULE_SYMBOL_H /* This ignores the intensely annoying "mapping symbols" found in ELF files. */ -static inline int is_mapping_symbol(const char *str, int is_riscv) +static inline int is_mapping_symbol(const char *str) { if (str[0] == '.' && str[1] == 'L') return true; if (str[0] == 'L' && str[1] == '0') return true; - /* - * RISC-V defines various special symbols that start with "$".  The - * mapping symbols, which exist to differentiate between incompatible - * instruction encodings when disassembling, show up all over the place - * and are generally not meant to be treated like other symbols.  So - * just ignore any of the special symbols. - */ - if (is_riscv) - return str[0] == '$'; - - return str[0] == '$' && - (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') - && (str[2] == '\0' || str[2] == '.'); + return str[0] == '$'; } #endif /* _LINUX_MODULE_SYMBOL_H */ diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 78a1ffc399d9..ef73ae7c8909 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -289,7 +289,7 @@ static const char *find_kallsyms_symbol(struct module *mod, * and inserted at a whim. */ if (*kallsyms_symbol_name(kallsyms, i) == '\0' || - is_mapping_symbol(kallsyms_symbol_name(kallsyms, i), IS_ENABLED(CONFIG_RISCV))) + is_mapping_symbol(kallsyms_symbol_name(kallsyms, i))) continue; if (thisval <= addr && thisval > bestval) { diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7c71429d6502..b29b29707f10 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1052,7 +1052,7 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) if (!name || !strlen(name)) return 0; - return !is_mapping_symbol(name, elf->hdr->e_machine == EM_RISCV); + return !is_mapping_symbol(name); } /* Look up the nearest symbol based on the section and the address */