From patchwork Fri Jun 9 07:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 105338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp781023vqr; Fri, 9 Jun 2023 00:58:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Qk+py4lZ71citjQbQZjtB5ehiiGP9cpvVKipIIPazGKeG0NlQ4M/pt5M8Mu4i1uPBpeDp X-Received: by 2002:a92:c68f:0:b0:329:583b:c54b with SMTP id o15-20020a92c68f000000b00329583bc54bmr853481ilg.22.1686297500271; Fri, 09 Jun 2023 00:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297500; cv=none; d=google.com; s=arc-20160816; b=ALtHTkoxSEub4siZvWvCPQYmd18MoEQWgL+DeXk7Wbb26099/ToqUsmx50evVXDONt DmxbMlvm9uXZtnhrHYnucWSYxrD8V480/DS4YGUDBZ0NHLBmBQF7shvrQggR2vfoMOU/ xZiOZ/p5bd2j2BV4rD6PqaFqWX7H3QwHH9a9uVJ7ZvGFgFrH5hye9NrMG98pB6J9sHse 0YbBa2OOayAwaqJwgHS+LmtNfvh0R5MWQCkIlg9yLuUkf+hjcQo5KCs/OPgGBTwZ3TQR 6ReJkqU9GuhYR3OeZaqXVQT8AplMnqUnv1GCd/Aa9NFdNZ1Lz80jmXr4WIYH6KV722vQ yMjw== 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=XKXAJiFZP7kJhI5XxgiKn7QvSsgCXvIR5vJXfnzrnPs=; b=PWpwAv/JPQCIhSbPBxDUa+lDSJqwTPiCqEBKU15zKC/fdGKF8HCytTBZQM1hlLYT7y xmJ6x1NmjJ389V9VhEL2+cju4rnsQJXdag3zDOc2fxTkM/G9MDxAWcTKp96dMcTlbUz/ nr5Yv7nSomhFw2I42GvWBZpEaM78o/oMjHWPOHluu1FuZFSdEcOKp8N8Ow8R79Gz3M9J Oo+ChiuCHxw9NL8oQ4onA6e5GBxGdructAPnosW0xw9IptHHIHpkFnzDslMd0JlfLNDa kDce5B9pXCaQ+b0ufD7pfaBh7C4Bc+WVjxNLBhx4cRQ+n3+9W9Alxd9jKe9pKGrBfjrA vsYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zbjX7AwT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a17090a55c200b0025679bf9761si2336684pjm.56.2023.06.09.00.58.07; Fri, 09 Jun 2023 00:58:20 -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=zbjX7AwT; 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 S238807AbjFIHrl (ORCPT + 99 others); Fri, 9 Jun 2023 03:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239057AbjFIHrf (ORCPT ); Fri, 9 Jun 2023 03:47:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A330E210C; Fri, 9 Jun 2023 00:47:27 -0700 (PDT) Date: Fri, 09 Jun 2023 07:47:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296846; 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=XKXAJiFZP7kJhI5XxgiKn7QvSsgCXvIR5vJXfnzrnPs=; b=zbjX7AwTsFo8+wHkJmSw6meWbjSR90bi6HPQlkb2RgN4cEIbr+xvedvQg/uXz90xXJtEMy 73O+U4onrh0EDgqu21nsv2yRnx7DUEOM6ZON5KuwcyLFQvoDZlKGjxu9AXXL9Ev5MIpkbw W158X4kkpNsqcN8DvJZ5fVLsip8+cd4cbo39mK0Q0UOU1eER3kV6HlFEff4wRrSdnW3qsg jFwlXKiw+WSHaiatpIuJKyVjT6UPOUcpE8VPGhGgPKfDl7SV9p+n1uES6KwpvOqthCl2Fh yAqVUx1aK+Xo3tcAMt3fMeLOoboL3FkWnW97SEu531kPTQhUL4YxkOs+7DJKnw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296846; 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=XKXAJiFZP7kJhI5XxgiKn7QvSsgCXvIR5vJXfnzrnPs=; b=fxec4OyE71Fk4/LsExSH3RmUGfo4lHfe13lhOYKl97i8zaqOLikGlgZ5FjIacPH1Yhh2Wp kEe7Oysmb+3oBOAw== 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: Skip reading DWARF section data Cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <52a9698835861dd35f2ec35c49f96d0bb39fb177.1685464332.git.jpoimboe@kernel.org> References: <52a9698835861dd35f2ec35c49f96d0bb39fb177.1685464332.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168629684573.404.10722273485724895229.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767341099521327022?= X-GMAIL-MSGID: =?utf-8?q?1768211087666258431?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: b4c96ef0add5b701eb37be9830a98610e1d9b4a3 Gitweb: https://git.kernel.org/tip/b4c96ef0add5b701eb37be9830a98610e1d9b4a3 Author: Josh Poimboeuf AuthorDate: Tue, 30 May 2023 10:21:14 -07:00 Committer: Josh Poimboeuf CommitterDate: Wed, 07 Jun 2023 10:03:27 -07:00 objtool: Skip reading DWARF section data Objtool doesn't use DWARF at all, and the DWARF sections' data take up a lot of memory. Skip reading them. Note this only skips the DWARF base sections, not the rela sections. The relas are needed because their symbol references may need to be reindexed if any local symbols get added by elf_create_symbol(). Also note the DWARF data will eventually be read by libelf anyway, when writing the object file. But that's fine, the goal here is to reduce *peak* memory usage, and the previous patch (which freed insn memory) gave some breathing room. So the allocation gets shifted to a later time, resulting in lower peak memory usage. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 29.93G - After: peak heap memory consumption: 25.47G Link: https://lore.kernel.org/r/52a9698835861dd35f2ec35c49f96d0bb39fb177.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 54d182d..d420b5d 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -300,6 +300,11 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns return find_reloc_by_dest_range(elf, sec, offset, 1); } +static bool is_dwarf_section(struct section *sec) +{ + return !strncmp(sec->name, ".debug_", 7); +} + static int read_sections(struct elf *elf) { Elf_Scn *s = NULL; @@ -350,7 +355,7 @@ static int read_sections(struct elf *elf) return -1; } - if (sec->sh.sh_size != 0) { + if (sec->sh.sh_size != 0 && !is_dwarf_section(sec)) { sec->data = elf_getdata(s, NULL); if (!sec->data) { WARN_ELF("elf_getdata");