From patchwork Fri May 5 19:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98659 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp292663qge; Fri, 5 May 2017 12:48:15 -0700 (PDT) X-Received: by 10.99.163.18 with SMTP id s18mr5269309pge.150.1494013695583; Fri, 05 May 2017 12:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494013695; cv=none; d=google.com; s=arc-20160816; b=IffSObncQX7sO0dFzc5zSW7Rh+sHoo4GE6t15mKGPgbDpl+2tSW7Darg6Nw/Y9fY2i sc5U+trinf73iekGkYhVg45M/ftgu9CJfJwMHrGPN8Xss1uB9nJXM2tbrbggN3WATAYM KqR246hh6YDrzxmLxlspk3IxAzXt9slWUM0xXNnWsRd4FsNfKb/YTE4vGaeX6g18KFdC U29Zw5tE4VuQcABrA0HetpIMPGur4+TMxibLnF35CkAeT09ah52TCnn3p5VTWkkdfwM0 Xs80MU4DObRFXz4TdV8xS1EG4xPuuhTluT0vO3L+W2yq97g0PjvsdoK3Qbq/3UqHHFXl 6Emg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=U6aIf0h9rEaRtgQIh/A0nJJHkufXJEnU9U5oHNxUCoY=; b=cdshcgASkeYS+aqSlupmXWDVwcTjzzHb9bysvDGPyha8LqUd5oaap8+S+xNWw67y9r tizsRQG96Kwz6n1TEHsJx/o1G1zjm8GUtXAyOlWYbBVbcBVf2kTFRuo4rZOYSb7H7va8 CQq7hvCHwxBMkeKYIvtX30ZVMLRsg+mbRRLLQtLh+Cm+5lzVHLMqeA4pUHzZdtU0W7ka QbodobV5eGwpEvBQz0cpNa0y96L58nTj3Jrpic4sXwwaVZOrdY+pXj3qoDGb86TBTwN0 ymLV9ojfqVlPZuDZ3wWLgCVOW3O/rsdrtsoMYz+6QnWjMvNPp8yJf1B42PVm4TDl9BjN +3kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 144si6012850pfa.118.2017.05.05.12.48.15; Fri, 05 May 2017 12:48:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755345AbdEETsO (ORCPT + 6 others); Fri, 5 May 2017 15:48:14 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:64780 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbdEETsK (ORCPT ); Fri, 5 May 2017 15:48:10 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LvcQG-1e7EqP1sPU-017TY9; Fri, 05 May 2017 21:47:57 +0200 From: Arnd Bergmann To: Ben Hutchings Cc: stable@vger.kernel.org, Paul Gortmaker , Rusty Russell , Arnd Bergmann Subject: [PATCH 3.16-stable 03/87] modpost: expand pattern matching to support substring matches Date: Fri, 5 May 2017 21:46:21 +0200 Message-Id: <20170505194745.3627137-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505194745.3627137-1-arnd@arndb.de> References: <20170505194745.3627137-1-arnd@arndb.de> X-Provags-ID: V03:K0:E/cxWvfe33VeEwGb8M6mbABUbC9jpxt15njYwkAbWtvvYgvnZxa uAwEoKWm9ntstIk9hvQoKQMJkRUR+yv0iC8p9SfdJXugMqy9HzXBcEoJVCb2JR/qjY37rNF YHKv366eOYy2ksZVC8wk3jCy/cgMjYcljStAky1F085i36GYGEYC9Se0qKBqikmLZ7ffhMY Ev+CHEFTlvYdEzp2WorsQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:2AR00kRXhC0=:wOpmKQwKFbqpthIr6ACoVf xZyh665KW6FnsoEJq7nzRtJ6UZPyEtVI4Cl1T5hWqc24IesjDHZRbpdwe0XsLXGD9BBa5MzUk M6oX0weIlEXGmsMgmLDXeHPjTxCd8SUQ6sD6JYc+oJWxxo6vhqu+iSZVloaHLw/XhhcZSH6ij Vj1QFGzy4wB7vEt60gmPecvwULv1Tl9465JvCUf/zoCAHAunCD4MOH3Lknml4QiYJoS6VA4Y+ 9DeMV2OunNWskL3WOFLg0HwQ0MksC36jzqLTGnRuAbVtvtAVUtar69AZKsDd7B8bwgOfud/1/ A3V+fVEST7NxbyfE5npvVFJ1kziZ7q1uBnC1SKybbRI9Qluh88aOQ2BSxcisGJ2c8u1bnhwdw QRIx4fTCe94RvH5F33/mWlExL6C4OrYhW/W0oKbIgiQ2c//wW6feZ9GDNA6PzseQ0lnOA+BF4 EmOHIg82HSHN4U194Dn/A1MN2WVKzjKaJAaoKZRDV9Vy+ooVYNRirnaOYYbc8PpbBPeooPOzu yBdqOSYDXICeF2UdiyBgXkWYqXLQUhnxQFTZJ+lpEVL0hENWMdUeZtgrAl/CzbF3DcgFZZfVB pn2pz002TJ4N7xSlaZJwtqVng/aexyR+QbC8EIfoVrB8aERAme05vVLxFhbItug0CAvJTmcZA HXpHBDb9ZhSkBXRbkJug8Jg8f/T7q8X0dAMarRslTgP39pjoCSYeGIyCSwd94WZ1uvVI= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paul Gortmaker Commit 09c20c032b0f753969ae778d9783d946f054d7fe upstream. Currently the match() function supports a leading * to match any prefix and a trailing * to match any suffix. However there currently is not a combination of both that can be used to target matches of whole families of functions that share a common substring. Here we expand the *foo and foo* match to also support *foo* with the goal of targeting compiler generated symbol names that contain strings like ".constprop." and ".isra." Signed-off-by: Paul Gortmaker Signed-off-by: Rusty Russell Signed-off-by: Arnd Bergmann --- scripts/mod/modpost.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9d9c5b905b35..14e3f53ebf17 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -798,6 +798,7 @@ static int number_prefix(const char *sym) * where the '1' can be any number including several digits. * The $ syntax is for sections where ld append a dot number * to make section name unique. + * "*foo*" will match a string that contains "foo" */ static int match(const char *sym, const char * const pat[]) { @@ -806,8 +807,17 @@ static int match(const char *sym, const char * const pat[]) p = *pat++; const char *endp = p + strlen(p) - 1; + /* "*foo*" */ + if (*p == '*' && *endp == '*') { + char *here, *bare = strndup(p + 1, strlen(p) - 2); + + here = strstr(sym, bare); + free(bare); + if (here != NULL) + return 1; + } /* "*foo" */ - if (*p == '*') { + else if (*p == '*') { if (strrcmp(sym, p + 1) == 0) return 1; }