From patchwork Sat Nov 23 16:04:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 180112 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp886834ilf; Sat, 23 Nov 2019 08:05:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxEHW726enxoyNjUu390VyadDTijJa9vKK6dkgHDpNrRjTtNpllJa0fXCeDHwvYKi7Rm95V X-Received: by 2002:a50:fc18:: with SMTP id i24mr7837218edr.41.1574525143469; Sat, 23 Nov 2019 08:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574525143; cv=none; d=google.com; s=arc-20160816; b=tdF28EjE4101+ZQTfKK27t4FLKpnYU/WVUzMrEDRghpQSSommDpxLBLdy7LGRzEkdK VRV9oqymfymavntOoUb8ytEjrzVnXJjiyNeulnir0EHYOSXh9dl3A4xcrJ1w1iKXy+op kPA16k0nnV+qEW1cJhZvW422igG6Mew0E0a7zeuKzqulEWayQiKvewvEztPKQxOTdA73 lq0M7Cj1O/U+ekxWZDc3c79onbotNBtyypmjMKdyINiU4gUPx3WKS9huRaVvNgvh01q5 of43X9oJLoZIhfRVokivgb+EZH7lrfjPln+Oi1QLN+mb8e/CuWgguaguGpfIbRUuGm2I b8tA== 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:dkim-signature:dkim-filter; bh=jnfvjcB5kg6ke5illdITerqCOO0i1ll9kEjlHRPbqGY=; b=pgbpfZhLmZ4m8H4Kleyu3AEgmn5rug2KKdMXqD4YI4978njME34iyfXPhvy9DuO7qq /F5eGuZrzHfAn+qdew4qETmvwUahufb4xrYgbKsgqdDyEYPWIvlLKuWqrXTR5IY/d7SP 7BB2b8achXA13b7lOopwcxD/+xy5QytkVysx6hrP1wpjil2AAqym+0XT/q3/jLwseF7L XAjm06W76+vDezzBSj+1dvHTOgRN9Roxr7yxhZAstIIqjQAouY1KAygbj0McilEMtl/2 sAb03JcsmSGDsvEJFk1f+xothCwiyhxEw7fXzRajJMP1nwJL4a71hrrrjxO00MOdt+pa IRkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FV5lkNil; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qn4si970396ejb.329.2019.11.23.08.05.43; Sat, 23 Nov 2019 08:05:43 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=FV5lkNil; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbfKWQFh (ORCPT + 26 others); Sat, 23 Nov 2019 11:05:37 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49450 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfKWQFC (ORCPT ); Sat, 23 Nov 2019 11:05:02 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5L019106; Sun, 24 Nov 2019 01:04:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5L019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525089; bh=jnfvjcB5kg6ke5illdITerqCOO0i1ll9kEjlHRPbqGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FV5lkNildmiiTubSxu06HhEHVwMSCweueZUvG39cNL4RC+2Y06tdbNeQ+n+4gIaOg mz8MvphMJNMQaJ77fuMEifS//aXw4yo9HUy9PjOK82SF5/FeffaWpAEqSIioZyKuh0 SoT0F1o60PUaujqnJDfQzyD5tLAVkUiJZycvr0+EieuQSf3oV4PUUYx1cGCNrl1bRN eryi/OfaiFCnoN0acxhAdZaF1H/VIl10EbSswtRhbbZZTi9aYciQdPd20LgXXIguiu Eh+B3GeDep7xVK/CPK2XKiNMlqnp520LumaCkvxPLZLcXnmCmjjN1+FY52EYIy2b2U 8vhLr9bI/+LkQ== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 04/16] scripts/kallsyms: set relative_base more effectively Date: Sun, 24 Nov 2019 01:04:32 +0900 Message-Id: <20191123160444.11251-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, record_relative_base() iterates over the entire table to find the minimum address, but it is not efficient because we sort the table anyway. After sort_symbol(), the table is sorted by address. (kallsyms parses the 'nm -n' output, so the data is already sorted by address, but this commit does not rely on it.) Move record_relative_base() after sort_symbols(), and take the first non-absolute symbol value. Signed-off-by: Masahiro Yamada --- Changes in v2: None scripts/kallsyms.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index de986eda41a6..c9efb67c6ecb 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -739,11 +739,15 @@ static void record_relative_base(void) { unsigned int i; - relative_base = -1ULL; for (i = 0; i < table_cnt; i++) - if (!symbol_absolute(&table[i]) && - table[i].addr < relative_base) + if (!symbol_absolute(&table[i])) { + /* + * The table is sorted by address. + * Take the first non-absolute symbol value. + */ relative_base = table[i].addr; + return; + } } int main(int argc, char **argv) @@ -767,9 +771,9 @@ int main(int argc, char **argv) shrink_table(); if (absolute_percpu) make_percpus_absolute(); + sort_symbols(); if (base_relative) record_relative_base(); - sort_symbols(); optimize_token_table(); write_src();