From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48281C43462 for ; Thu, 1 Apr 2021 17:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CA9F61155 for ; Thu, 1 Apr 2021 17:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234728AbhDARwB (ORCPT ); Thu, 1 Apr 2021 13:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbhDARkx (ORCPT ); Thu, 1 Apr 2021 13:40:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E42CC00F7DF; Thu, 1 Apr 2021 08:08:59 -0700 (PDT) Date: Thu, 01 Apr 2021 15:08:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1617289736; 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=c7PX5AnAr8nq3pYt8IX3dW6sMpPFXAd/ofQR1KSuruY=; b=O69gGr4PQ2IAMx3ttd4I4gjKlQeME+0xJw+b5yTny7NcTxnmhB2asaNdFy35WrorEOrboz LgRHgURYZQR+wN8svX3RI21FzHZgrem+vUaxQL3beueEwwvIWjgTfdtRf9sQYJSNI4fueW KzgJ3G/uigIaUj+X9UCcZLRCG1TTYHy7CTFAiKpwtIwNEaj+E4RulrQsnVr0gsfrLrx+GS 6YbHaWQFw0VPelDDRWtV/onJjWp7sezBlIgx1m1JQrIqs3Gmhl7f17e/mQQrBd7WliQZ8G Ky9G0vf8lBf8v+UrXqwBqRjU9q3nKAC1KLXQFohWqtfGQkKtDSMFrU/0PXlQsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1617289736; 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=c7PX5AnAr8nq3pYt8IX3dW6sMpPFXAd/ofQR1KSuruY=; b=1rpAaK62LjlP2lplOcroBJMkCnk7xxlWhdza0QGqi3nAFJJFVgYWF4FFFhzNwOM36TIKbI ESjUsNrXsPbNH2AA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] objtool: Implicitly create reloc sections Cc: Josh Poimboeuf , "Peter Zijlstra (Intel)" , Borislav Petkov , Miroslav Benes , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210326151259.880174448@infradead.org> References: <20210326151259.880174448@infradead.org> MIME-Version: 1.0 Message-ID: <161728973626.29796.13144377125307470696.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/core branch of tip: Commit-ID: aef0f13e96db08f31be6b96d28e761df46d86ff4 Gitweb: https://git.kernel.org/tip/aef0f13e96db08f31be6b96d28e761df46d86ff4 Author: Peter Zijlstra AuthorDate: Fri, 26 Mar 2021 16:12:08 +01:00 Committer: Borislav Petkov CommitterDate: Thu, 01 Apr 2021 13:01:15 +02:00 objtool: Implicitly create reloc sections Have elf_add_reloc() create the relocation section implicitly. Suggested-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Borislav Petkov Reviewed-by: Miroslav Benes Link: https://lkml.kernel.org/r/20210326151259.880174448@infradead.org --- tools/objtool/check.c | 6 ------ tools/objtool/elf.c | 9 ++++++++- tools/objtool/include/objtool/elf.h | 1 - tools/objtool/orc_gen.c | 2 -- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 61fe29a..600fa67 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -459,9 +459,6 @@ static int create_static_call_sections(struct objtool_file *file) if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; - idx = 0; list_for_each_entry(insn, &file->static_call_list, static_call_node) { @@ -547,9 +544,6 @@ static int create_mcount_loc_sections(struct objtool_file *file) if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; - idx = 0; list_for_each_entry(insn, &file->mcount_loc_list, mcount_loc_node) { diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 0ab52ac..7b65ae3 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -447,11 +447,18 @@ err: return -1; } +static struct section *elf_create_reloc_section(struct elf *elf, + struct section *base, + int reltype); + int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct symbol *sym, int addend) { struct reloc *reloc; + if (!sec->reloc && !elf_create_reloc_section(elf, sec, SHT_RELA)) + return -1; + reloc = malloc(sizeof(*reloc)); if (!reloc) { perror("malloc"); @@ -829,7 +836,7 @@ static struct section *elf_create_rela_reloc_section(struct elf *elf, struct sec return sec; } -struct section *elf_create_reloc_section(struct elf *elf, +static struct section *elf_create_reloc_section(struct elf *elf, struct section *base, int reltype) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index 825ad32..463f329 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -122,7 +122,6 @@ static inline u32 reloc_hash(struct reloc *reloc) struct elf *elf_open_read(const char *name, int flags); struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); -struct section *elf_create_reloc_section(struct elf *elf, struct section *base, int reltype); int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct symbol *sym, int addend); diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 1b57be6..dc9b7dd 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -225,8 +225,6 @@ int orc_create(struct objtool_file *file) sec = elf_create_section(file->elf, ".orc_unwind_ip", 0, sizeof(int), nr); if (!sec) return -1; - if (!elf_create_reloc_section(file->elf, sec, SHT_RELA)) - return -1; /* Write ORC entries to sections: */ list_for_each_entry(entry, &orc_list, list) {