Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1726158rwd; Fri, 9 Jun 2023 00:56:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yViipu0o2Hxx2pbrNza7yAFG1JNBFYyEKQ/fAlJsSfHtTFvBLEG/92FVQ7yrBk465T3Bj X-Received: by 2002:a05:6102:2850:b0:43c:381f:8412 with SMTP id az16-20020a056102285000b0043c381f8412mr459955vsb.16.1686297401404; Fri, 09 Jun 2023 00:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297401; cv=none; d=google.com; s=arc-20160816; b=uSsyAcAGGCJqtgDRsrTZpC1/gJwY9XTZ+yzFnTUzFTVQ8D7XorrOO1REiPOHtnGkk3 4/AUvljElXVeg3tkxbPXrPA6BuQEG84wU4Hult4X6oh3HG13XJtI4OhW+S4PPChTbIUp WBKnh89upROhswRmEIoAvW+L1GIcQrm0JsWr2VlGlzTshwT9TikocxUa3aRlKkZqmHb9 b2sVGFZKJOvtUTlKKAMFM03DVLmwJBSjyKvbMvIW7xaEKHv7joAKO/d6CCjBwYqq7OQO 19Epe4U1oLYg8SDHQQa/BPYece0/cV3hphA/guwy3ynH1Ke7EfKQp8PO4WyHeasEXZqv YK4A== 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=706pUqJ1rxVQuZQlYVkYva1NebzBF1ueHcAL4F1w4kg=; b=FPumvaA78FwCrzlAyL9Hwvi47GWgIKW+Umd+Fv/l9CmEAvgjaOBOaYtekXzIm0bqti D+ka8Of3yMA732NmKTeFstY2Ie3OGS/qjl4ZrCYC7yPqmDZTkuLw/iB6fqmjOFCq0SQc Nv3DpIclw6qpq1DmXh8yrK1C0Dj2RfryEkQhMUGt26NHDf8ockR6PFK9VunTJ+xmrlss icanLr1Oq5j4S76I3Zprn8S45SXMlF2tv3X/08YSPEoWvDBxpk566pAGbjM/A66zhFAW SM69my92WQVdWq2zeKCXqCD1z72CHazk0meZ2od9lkSzii46dpKV8748PFrxZ9HjBNba reJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=215sTCQ5; dkim=neutral (no key) header.i=@linutronix.de; 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 s204-20020a632cd5000000b00541cfaad532si2234009pgs.613.2023.06.09.00.56.29; Fri, 09 Jun 2023 00:56:41 -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=215sTCQ5; dkim=neutral (no key) header.i=@linutronix.de; 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 S239241AbjFIHsW (ORCPT + 99 others); Fri, 9 Jun 2023 03:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239057AbjFIHrm (ORCPT ); Fri, 9 Jun 2023 03:47:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E0E530F5; Fri, 9 Jun 2023 00:47:40 -0700 (PDT) Date: Fri, 09 Jun 2023 07:47:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296853; 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=706pUqJ1rxVQuZQlYVkYva1NebzBF1ueHcAL4F1w4kg=; b=215sTCQ5yYQdwnrjV9K5sqr5mwxgfpm4IZjge0cDksEfGbc2Z4PG5ZPcFfSxZ+i5fhZ7zI UxemA1uUMvuLaYlCzgc0IgpgeS4vNc1ORCO33SrHtnNfsge33+At4fMqo5IVHw7sPp+hh2 HneFmBpNDSj8Eh/MmHIcZQQlgwBzmEYZt/AIGHQBTdifkXIAopRf7B0DTJOQQUjd6qnlo9 DaHW9WP+bQ5viAO8Zdmu07sNxQZ/RwgmrmU2A4By0gbFgVZgISqL1pfX8qdLFEYXUrDQzV qjivYeaGovhgCY5yDbrOy+JzX7PsvESrbTg4cjaUSEwF4f3HT4hQZPNSQkodZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296853; 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=706pUqJ1rxVQuZQlYVkYva1NebzBF1ueHcAL4F1w4kg=; b=PpGYaGTavtDzCm7x+v3ANT46XbkAkvDgE/7qxEhx4KUyNAXyPme/2uvWSr68EwXj35EW+A /J6drpHvggtJO9Bg== 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: Allocate relocs in advance for new rela sections Cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <5332d845c5a2d6c2d052075b381bfba8bcb67ed5.1685464332.git.jpoimboe@kernel.org> References: <5332d845c5a2d6c2d052075b381bfba8bcb67ed5.1685464332.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <168629685285.404.18154288626119314332.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: e0a9349b4c590145c6a83e6c9f7701cec42debbd Gitweb: https://git.kernel.org/tip/e0a9349b4c590145c6a83e6c9f7701cec42debbd Author: Josh Poimboeuf AuthorDate: Tue, 30 May 2023 10:21:03 -07:00 Committer: Josh Poimboeuf CommitterDate: Wed, 07 Jun 2023 10:03:20 -07:00 objtool: Allocate relocs in advance for new rela sections Similar to read_relocs(), allocate the reloc structs all together in an array rather than allocating them one at a time. Link: https://lore.kernel.org/r/5332d845c5a2d6c2d052075b381bfba8bcb67ed5.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 8d53f18..5f69d45 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -814,7 +814,7 @@ static struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec, unsigned long offset, struct symbol *sym, s64 addend, unsigned int type) { - struct reloc *reloc; + struct reloc *reloc, empty = { 0 }; if (reloc_idx >= rsec->sh.sh_size / elf_rela_size(elf)) { WARN("%s: bad reloc_idx %u for %s with size 0x%lx", @@ -822,12 +822,13 @@ static struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec, return NULL; } - reloc = malloc(sizeof(*reloc)); - if (!reloc) { - perror("malloc"); + reloc = &rsec->reloc_data[reloc_idx]; + + if (memcmp(reloc, &empty, sizeof(empty))) { + WARN("%s: %s: reloc %d already initialized!", + __func__, rsec->name, reloc_idx); return NULL; } - memset(reloc, 0, sizeof(*reloc)); reloc->idx = reloc_idx; reloc->sec = rsec; @@ -1185,6 +1186,13 @@ static struct section *elf_create_rela_section(struct elf *elf, rsec->sh.sh_info = sec->idx; rsec->sh.sh_flags = SHF_INFO_LINK; + rsec->reloc_data = calloc(rsec->sh.sh_size / rsec->sh.sh_entsize, + sizeof(struct reloc)); + if (!rsec->reloc_data) { + perror("calloc"); + return NULL; + } + sec->rsec = rsec; rsec->base = sec;