Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2500983ybp; Thu, 10 Oct 2019 08:16:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ3e3f/61HsxzPzpIoYmWl7sXuO/hxxaAxcYIOFibjg43v2iVHbXk8mO6soCg7+pavYAIc X-Received: by 2002:a17:907:365:: with SMTP id rs5mr8784180ejb.121.1570720604980; Thu, 10 Oct 2019 08:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570720604; cv=none; d=google.com; s=arc-20160816; b=Rlo5hbrTvICyM6vzFU0oQqGqs2Fjatp5Sh/glMznzkUpqcy12jGfjPB16tRZrySWi8 5V2PpZRr86OHNibz0mxdcaNMZfufAPvlIg22YHbBCcUPreTasE3nN9kYIQVDb1IQ/NaR JrtP44HmkhqYMOnmYBgcUct+11A4WVPrdDmd1W0zIBcsWVYr9DJPrIirIcJ5mJJccHzK dxvUfQSAkGvtb1OsVJ3RNWdu7oy0begfJUvrHs9353dtOe+df7dMqpfN/vu0K3L+xAUX qiz+ZyevMFSScKXqfyBXqjpgcFulpH++Ao20d4QA6Z1S1DMChCG/xDpY9F2EuNNSFyr3 Pjag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=IzMPe/tjamSa0KLYQxTKRfMo0szpHPyKHH63Rc8COQE=; b=qCEhpfH5HXg7cl1gCdaIfjKy6K03OmYbAxXoFdhqlier3OdcjSHyvAumN3SaJtB3Xn elY0nBn1xtKoGtCJpIz+UPDBlpYTa9brN6xLBlR0YzMCIP42pXm6BXAdjG6G50fxqzva L77/+gtnoDRHMRLb8s1HtckWeA/efTmzxCbpJVIDaipHn8xAr3XB1gfUqo3FkQTW8fHP 8Wu/8tiMU286lvD88o/nUvMvBCalJSF7QJJvX4ZpzZacGrgYYANLF+q70pQE0oWO88Sc M8zXmwBzv8OCpkgaICyYlZMRRVivZO4sokdCyMiT6egV9JF2oLVWxQ2TCcN5TocgilBl yklA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CEhsoKqb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v20si3354509edq.195.2019.10.10.08.16.20; Thu, 10 Oct 2019 08:16:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CEhsoKqb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726496AbfJJPQG (ORCPT + 99 others); Thu, 10 Oct 2019 11:16:06 -0400 Received: from mail-wm1-f73.google.com ([209.85.128.73]:43994 "EHLO mail-wm1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbfJJPQF (ORCPT ); Thu, 10 Oct 2019 11:16:05 -0400 Received: by mail-wm1-f73.google.com with SMTP id l3so2757729wmf.8 for ; Thu, 10 Oct 2019 08:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=IzMPe/tjamSa0KLYQxTKRfMo0szpHPyKHH63Rc8COQE=; b=CEhsoKqb1NUOR2q9K12j5UZX10yW1wI2M3yPsx7L52TxlBGNCNvfJ8OpKpFeodUWNO A8V/AN3q5wNrJ4f2inCZFsdFJRT8MoUDRp4LP77DqdmmB5/2jnF0zZMk1UzqK9rmTIZN 7fQFJyk6lzYIeOtWenG5f9RdXOyf5j6OrG914HRXCGVMNAOZURmjzdtQkUvdMfdy3Wq1 9/iZ0Yap9Hol6k0NlLwvulKLYBo3qG7C9XQzwpqGYI0RZmuzQZXQvkhOtKJ4yXwrpHgi D1uQQmY72bE6vHjTxMJalR8KGShZmbyMybxZQDzfEsFjGhTX15OtTM3Ol9doWeF1+ihk x69Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IzMPe/tjamSa0KLYQxTKRfMo0szpHPyKHH63Rc8COQE=; b=j16TVOkXoCdtDMgUul6EKK5UeMTZ0Rd2VW3XO0PRffgBQT3xYUCVkO4ZmFjFBMTXG8 yPxu/iryM/Cp41iiGdOPrlvNLaAne6zkbdudKsDuOBHoc8STamzc+ssTSHpQEPVa+ixg 2va1PGTSjeawy56KKGCa+scgPdpWAWw9F/OsD0KhZQdBGNAuVKgPDhByXuufBQAb184S 2NvuXzpNOtW6FMFKSoOpB1V26S/0zOP3qD8GCvoW8YkPKgmxdnj4VpmxfjERGZjyRNpH H6rRCChhGDk5DBpWIW3+dMKLr6bNbxF52rPAo6eu4ANtonO607sayYAdP5xdYlJlhy5z 8caw== X-Gm-Message-State: APjAAAVa7ms57/tOawodIYch+ywaH8qceo/LnhkA64o59G1/Y5sq0KD2 kMosc+dBv44XibK7Zk4A4nasQ8jpGbKS/OkBEx3uzcZuyaVN9y+pnU/oCQeBGKkAo0Kafy3xuiX C/LKaqM+rIeOb96NPOq8cqZrFmcaNGEZWe7E082g7sTIASkLuz+f104lma6qHApiE5dShIMCYMR U= X-Received: by 2002:adf:9cca:: with SMTP id h10mr8720719wre.339.1570720563350; Thu, 10 Oct 2019 08:16:03 -0700 (PDT) Date: Thu, 10 Oct 2019 16:14:40 +0100 In-Reply-To: <20191010151443.7399-1-maennich@google.com> Message-Id: <20191010151443.7399-2-maennich@google.com> Mime-Version: 1.0 References: <20191010151443.7399-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.581.g78d2f28ef7-goog Subject: [PATCH 1/4] modpost: delegate updating namespaces to separate function From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, Jessica Yu , Masahiro Yamada , Martijn Coenen , Lucas De Marchi , Shaun Ruffell , Greg Kroah-Hartman , Will Deacon , linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let the function 'sym_update_namespace' take care of updating the namespace for a symbol. While this currently only replaces one single location where namespaces are updated, in a following patch, this function will get more call sites. The function signature is intentionally close to sym_update_crc and taking the name by char* seems like unnecessary work as the symbol has to be looked up again. In a later patch of this series, this concern will be addressed. This function ensures that symbol::namespace is either NULL or has a valid non-empty value. Previously, the empty string was considered 'no namespace' as well and this lead to confusion. Signed-off-by: Matthias Maennich --- scripts/mod/modpost.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4d2cdb4d71e3..9f5dcdff4d2f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -362,6 +362,22 @@ static char *sym_extract_namespace(const char **symname) return namespace; } +static void sym_update_namespace(const char *symname, const char *namespace) +{ + struct symbol *s = find_symbol(symname); + /* That symbol should have been created earlier and thus this is + * actually an assertion. */ + if (!s) { + merror("Could not update namespace(%s) for symbol %s\n", + namespace, symname); + return; + } + + free(s->namespace); + s->namespace = + namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL; +} + /** * Add an exported symbol - it may have already been added without a * CRC, in this case just update the CRC @@ -383,8 +399,7 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, s->module = mod; } } - free(s->namespace); - s->namespace = namespace ? strdup(namespace) : NULL; + sym_update_namespace(name, namespace); s->preloaded = 0; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; @@ -2196,7 +2211,7 @@ static int check_exports(struct module *mod) else basename = mod->name; - if (exp->namespace && exp->namespace[0]) { + if (exp->namespace) { add_namespace(&mod->required_namespaces, exp->namespace); -- 2.23.0.581.g78d2f28ef7-goog