Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp773883ybc; Sat, 23 Nov 2019 08:07:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxwRIAlOI70/WsIG57ZgfemUkcG6XECwPcmKnMJ5giES82ZCtdzWXBBqjNuPVpUsuH9/uvW X-Received: by 2002:a50:9b43:: with SMTP id a3mr7832863edj.73.1574525253820; Sat, 23 Nov 2019 08:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574525253; cv=none; d=google.com; s=arc-20160816; b=ct4yrb3R2AQ10A3YTEl6nNKRT/VrxzV6lS5MHvK+DQ/W/zNK6ThpLlmvA5T+2Or8nc uuJYHtx3cvkzHLBXkLinSkSeLYQUn/2rp1hBKpWdbmuVslnsIvvQOdFXzeddNHZ6+RE4 MzOssIhewIWUqxNYVHamYsxlIPd4cIOU+u72PugVDpzfQGUbWZmZWE5YyjTnG/qgIGJm jiKdF1gE1oY8WhgeQzZqIzdB+RwGSsuIIB6Nr7YeF0Zr4AV7bxCfTLgYuCpuZWa47I3n 8JkouZulG9hn5A9Q9eJDR04+iABy1Yz5QKMITxYDyI7Y/8v2uBoNC/4Ht3DJYGntB8MV w93g== 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 b19si1164436edb.40.2019.11.23.08.07.09; Sat, 23 Nov 2019 08:07:33 -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 S1727187AbfKWQFg (ORCPT + 99 others); Sat, 23 Nov 2019 11:05:36 -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(-) 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(); -- 2.17.1