Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4827705rwd; Tue, 30 May 2023 10:25:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MdwZB/0vyJbRVzdHFb/kN9N/nCgy5OCLJ0qOSooddRUDztE6EBXwfxp5KglRbRHilDja9 X-Received: by 2002:a17:90a:a58b:b0:256:d4a:ea4c with SMTP id b11-20020a17090aa58b00b002560d4aea4cmr3102256pjq.30.1685467502083; Tue, 30 May 2023 10:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685467502; cv=none; d=google.com; s=arc-20160816; b=w+1/Vy0VkSPqLLiFZwJeryZW9HAQ0qIjHPJicAbpYVl9e4unIR6ZXG1nHRcIgA8i5F moofsMApw1UbYZo7b7cRgeT2dPZIZWlTtFO8Uv6ldrvYH1396AnGMf/9zopwsarXfmfw XdBf/c4YFLzlVGUjIFQZiW5Q5EKmB3gGzOLMf/fAso55IUd5+TCMMS+thC5nPHeCoTOg e8D9Ir6yyqytqxeoEXI5SsCvx9CEQS1bbMzCKg/5XjNL7xl68T/yMiZi+eaQj87ifg+8 DIyY2+FK+7F8ldYEy5waqkN366XCPG/jsQx1Cm+VjVJ+/3qsUZEPsNEPks6ynm8ZPOav ct0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7g55zyK5B7gX+9R4n0TzKnmmAWJQa5O83b4lRfwVVSY=; b=u7oLRJTIWk+GETK8rZScENHazhYQLPWVrvIaySpC+TaAvLmVaWuW1qDq6TxYqsVIxm XmkJJ4ahXOcerVuy82YKbTO8Ek9WOD0RoY5U67qJz6Wo59EZfwz6GWUVy5v8eM/cEi9f wGqyYNHFdMQ+ZOiYWc/3imurtW096Jg0NQNaGfN3xIijwd2ac+Hiygs80pd2O0W+w/OX bftBliwh/MCB5P/HshYMfizzmutXznIblJ6Uti5lnUUEtldiACQA/2XzCrGZj5DCTVl5 To4IZeDG95sgOWkNjwXEzWU6ACGQfJIJETpeJ2Yvx5qOc590nBHhlEfXzWNpW88j+uUn xZkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k+M69oU7; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np12-20020a17090b4c4c00b002532e1993basi2803671pjb.154.2023.05.30.10.24.45; Tue, 30 May 2023 10:25:02 -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=@kernel.org header.s=k20201202 header.b=k+M69oU7; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233445AbjE3RWq (ORCPT + 99 others); Tue, 30 May 2023 13:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233239AbjE3RVo (ORCPT ); Tue, 30 May 2023 13:21:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFB8EA for ; Tue, 30 May 2023 10:21:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 79AD46312F for ; Tue, 30 May 2023 17:21:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B34F1C4339C; Tue, 30 May 2023 17:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685467297; bh=nigN3+rTGBIIkX5YK6qdZ6MMc2ZnMKe0BoHwqwd6Fek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+M69oU78MdEJXI9LIn8c8i+fZkQYa9WPHxaS7CmX1iegENkA4232pAZH69B9HoqJ gmi3V7rp7vybp+7CWaT/0eEdY8DlRPQ6yKIMUwuUlpjj8hukrXmFPcECoyZfetQoM7 JiM/R6ngcsJ2ZM3NSb7N41q5/82mOAjwA4pmu+KgNzeOUNNHTLuMrvuOy61VOWSUvs bz8voy/GPaqTFwsQaJJxqSvYvj7jDe2krDOXRDXtrYT8mzuV/D2kPRr5EKKjcWKeBE ZH7w2jSv80Jo302rCgG7EWji026vEv+VJG6S1SG8vFmbSYNXSxd4ZmhIcCyAwLTMbP /6R5MLlk8dn7A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH 17/22] objtool: Get rid of reloc->jump_table_start Date: Tue, 30 May 2023 10:21:09 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Rework the jump table logic slightly so 'jump_table_start' is no longer needed. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 40.37G - After: peak heap memory consumption: 38.64G Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 35 +++++++++++++++++++---------- tools/objtool/include/objtool/elf.h | 1 - 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 12a9e6fb3fe7..3fe6b3657e22 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1988,13 +1988,14 @@ static int add_special_section_alts(struct objtool_file *file) } static int add_jump_table(struct objtool_file *file, struct instruction *insn, - struct reloc *table) + struct reloc *next_table) { - struct reloc *reloc = table; - struct instruction *dest_insn; - struct alternative *alt; struct symbol *pfunc = insn_func(insn)->pfunc; + struct reloc *table = insn_jump_table(insn); + struct instruction *dest_insn; unsigned int prev_offset = 0; + struct reloc *reloc = table; + struct alternative *alt; /* * Each @reloc is a switch table relocation which points to the target @@ -2003,7 +2004,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn, for_each_reloc_from(table->sec, reloc) { /* Check for the end of the table: */ - if (reloc != table && reloc->jump_table_start) + if (reloc != table && reloc == next_table) break; /* Make sure the table entries are consecutive: */ @@ -2118,29 +2119,39 @@ static void mark_func_jump_tables(struct objtool_file *file, continue; reloc = find_jump_table(file, func, insn); - if (reloc) { - reloc->jump_table_start = true; + if (reloc) insn->_jump_table = reloc; - } } } static int add_func_jump_tables(struct objtool_file *file, struct symbol *func) { - struct instruction *insn; - int ret; + struct instruction *insn, *insn_t1 = NULL, *insn_t2; + int ret = 0; func_for_each_insn(file, func, insn) { if (!insn_jump_table(insn)) continue; - ret = add_jump_table(file, insn, insn_jump_table(insn)); + if (!insn_t1) { + insn_t1 = insn; + continue; + } + + insn_t2 = insn; + + ret = add_jump_table(file, insn_t1, insn_jump_table(insn_t2)); if (ret) return ret; + + insn_t1 = insn_t2; } - return 0; + if (insn_t1) + ret = add_jump_table(file, insn_t1, NULL); + + return ret; } /* diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index be08b32a93ee..60686f746c9e 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -75,7 +75,6 @@ struct reloc { struct section *sec; struct symbol *sym; struct list_head sym_reloc_entry; - bool jump_table_start; }; struct elf { -- 2.40.1