Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1723001rwd; Fri, 9 Jun 2023 00:53:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7a5eij4LQHC684+1Ikztoej4g7ZBb5gjFpfrgOOdVEX83nToxmicyMgRpUtBJZcEkaI7yF X-Received: by 2002:a17:903:2350:b0:1ae:5f7e:c117 with SMTP id c16-20020a170903235000b001ae5f7ec117mr719293plh.60.1686297180802; Fri, 09 Jun 2023 00:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297180; cv=none; d=google.com; s=arc-20160816; b=GIe0vBc4xCNnGpki7FrUC9YigIFd3/K2ZyTz1MXcuEOBZsWbcWcrxU4Tp+7BgULYRv 1lRwL5XJ2gpNlYppKL6xSPGC8lHElCe8GtHh1glISApPCH4NdaoXbfFuZf7lJQHo/K+M fyU06gHK93rluJXEF1uIn2wtbeNYMFHpcyXoGxtVbUYFVd4thWpnixvs4pozL6GjW47A 0EBHU5eVyG9G4u+sviIh3eKZEC71jdsLdw/XnF/cFhgdax3Mlj7c6BIl0EU+1TEWLo+j RwF5ya4sxINha6KAkXu9HIYrLLP05nZetLYNOJd8HQxoJhllYWC8nXytZ3fKQnXZ6Oug 5YDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=I1QjFx25a8QTH/dzubQvtPLDE1NUoR24eLALObuUbSg=; b=Qc7UYU9CYnQEwNS7VSqqJ9Ip188+OYaZclE5VOxf/X/oRdI8Oc8NUau6ZiZUcexIBb pLosU70NSzlCa9D0dYfbyUNH7PD3dMYHexfiUA/GQh3CzSuDMahhpiZ9M503xpF3XxGU aywnTxAMK/SRehAktsha/VaYev9dnSYx+LKJ7cUzp6F9QEWOD7s/HSmw0awoQVlOJvYb cHviSqzO1qz0V8cX5cn9porGhedFfTwsvHxdsWMpOn4GF11UCKqhOoWvxadCcVmV2ZLr xLXCl9iQCiFyzrfYmvRg7FPSCEnMgfREdR1+08LdfZDZ6fDtaTVWXqmG38PxYWpPkrYU 5k1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3blPo3mD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a170902dcca00b001a664075202si2266227pll.542.2023.06.09.00.52.48; Fri, 09 Jun 2023 00:53:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3blPo3mD; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239296AbjFIHs1 (ORCPT + 99 others); Fri, 9 Jun 2023 03:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239069AbjFIHrm (ORCPT ); Fri, 9 Jun 2023 03:47:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FECC210C; Fri, 9 Jun 2023 00:47:40 -0700 (PDT) Date: Fri, 09 Jun 2023 07:47:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296852; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I1QjFx25a8QTH/dzubQvtPLDE1NUoR24eLALObuUbSg=; b=3blPo3mDsiV2HYY0n9H6byKre1/q+kDXiBeMIRW28pHp0bKqjushonaRwD3Wwq1fQnGxy5 fAIkyIoqLgqI7lX8L/JZO1exl32Qnucek/JGXzo8Z5tvrx59rxmIkCQ3WfXv9i5bH/iBk7 +YThbdTJAOBg8hC1E1lDM39rIJHfh109dHVN2AQIWAlDncIinxPdPzOG5gaFx7mo23wGRG FCq7XBqrHDLOn5VhTf0EGkHq2mScT6HLYl3uyVM/FOA6ft2YGwl2YS35acat3HW7AIcHQf 46fg7e4eaVBK0gshYiNEhVJzTXzCrj7IeCDsYQB8ScsPcXgEdVApVgErkq7ibA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296852; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I1QjFx25a8QTH/dzubQvtPLDE1NUoR24eLALObuUbSg=; b=B6TFGray1JRom/ORFJkugovknSf/Bm3PPf73rL5WEcq/RRxjFm9vUsBETAwN6dOke5d70r 647xxBSErvwQmpAg== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Get rid of reloc->idx Cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <7351d2ebad0519027db14a32f6204af84952574a.1685464332.git.jpoimboe@kernel.org> References: <7351d2ebad0519027db14a32f6204af84952574a.1685464332.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168629685158.404.4699012820536375293.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: be9a4c116824c39720001db5bc45fe7528b26cff Gitweb: https://git.kernel.org/tip/be9a4c116824c39720001db5bc45fe7528b26cff Author: Josh Poimboeuf AuthorDate: Tue, 30 May 2023 10:21:05 -07:00 Committer: Josh Poimboeuf CommitterDate: Wed, 07 Jun 2023 10:03:21 -07:00 objtool: Get rid of reloc->idx Use the array offset to calculate the reloc index. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 45.56G - After: peak heap memory consumption: 43.83G Link: https://lore.kernel.org/r/7351d2ebad0519027db14a32f6204af84952574a.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 6 ++---- tools/objtool/include/objtool/elf.h | 10 +++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 19ac53a..70c8012 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -829,7 +829,6 @@ static struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec, return NULL; } - reloc->idx = reloc_idx; reloc->sec = rsec; reloc->offset = offset; reloc->type = type; @@ -954,7 +953,6 @@ static int read_relocs(struct elf *elf) return -1; reloc->sec = rsec; - reloc->idx = i; symndx = GELF_R_SYM(reloc->rel.r_info); reloc->sym = sym = find_symbol_by_index(elf, symndx); if (!reloc->sym) { @@ -1237,9 +1235,9 @@ int elf_write_reloc(struct elf *elf, struct reloc *reloc) if (rsec->sh.sh_type == SHT_RELA) { reloc->rela.r_addend = reloc->addend; - ret = gelf_update_rela(rsec->data, reloc->idx, &reloc->rela); + ret = gelf_update_rela(rsec->data, reloc_idx(reloc), &reloc->rela); } else { - ret = gelf_update_rel(rsec->data, reloc->idx, &reloc->rel); + ret = gelf_update_rel(rsec->data, reloc_idx(reloc), &reloc->rel); } if (!ret) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index a09da20..2a14da6 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -76,9 +76,8 @@ struct reloc { struct symbol *sym; struct list_head sym_reloc_entry; unsigned long offset; - unsigned int type; s64 addend; - int idx; + unsigned int type; bool jump_table_start; }; @@ -200,6 +199,11 @@ static inline unsigned int sec_num_entries(struct section *sec) return sec->sh.sh_size / sec->sh.sh_entsize; } +static inline unsigned int reloc_idx(struct reloc *reloc) +{ + return reloc - reloc->sec->relocs; +} + #define for_each_sec(file, sec) \ list_for_each_entry(sec, &file->elf->sections, list) @@ -219,7 +223,7 @@ static inline unsigned int sec_num_entries(struct section *sec) __i++, reloc++) #define for_each_reloc_from(rsec, reloc) \ - for (int __i = reloc->idx; \ + for (int __i = reloc_idx(reloc); \ __i < sec_num_entries(rsec); \ __i++, reloc++)