From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABFEDCA5C; Tue, 5 Dec 2023 03:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qZ6RGeeu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AF6C433C8; Tue, 5 Dec 2023 03:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1701747628; bh=obpTu6KiHLJicRTgRbzW3o0eCw/CP5PoNP37h3yQDUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZ6RGeeuvDN47LF9RWzVfyfbQiFGBSB+DY8wj2WECf9TWsyIM4WSfqe8OFPmRCPxJ bACVXQOmjba6BcPV9W11+CwPrtS+qjMtjIK/5qVSURP5xyOEuDW6Z3e3J2NugNCBvp uqTQ6VHVGqYjWZz5NAm0HpE7QkvZFWCwtGzTKFoI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Hunter , Arnaldo Carvalho de Melo , Ian Rogers , Jiri Olsa , Lieven Hey , Namhyung Kim Subject: [PATCH 5.15 01/67] perf inject: Fix GEN_ELF_TEXT_OFFSET for jit Date: Tue, 5 Dec 2023 12:16:46 +0900 Message-ID: <20231205031519.942251301@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205031519.853779502@linuxfoundation.org> References: <20231205031519.853779502@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit 89b15d00527b7825ff19130ed83478e80e3fae99 upstream. When a program header was added, it moved the text section but GEN_ELF_TEXT_OFFSET was not updated. Fix by adding the program header size and aligning. Fixes: babd04386b1df8c3 ("perf jit: Include program header in ELF files") Signed-off-by: Adrian Hunter Tested-by: Arnaldo Carvalho de Melo Cc: Ian Rogers Cc: Jiri Olsa Cc: Lieven Hey Cc: Namhyung Kim Link: https://lore.kernel.org/r/20221014170905.64069-7-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Cc: Namhyung Kim Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/genelf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/tools/perf/util/genelf.h +++ b/tools/perf/util/genelf.h @@ -2,6 +2,8 @@ #ifndef __GENELF_H__ #define __GENELF_H__ +#include + /* genelf.c */ int jit_write_elf(int fd, uint64_t code_addr, const char *sym, const void *code, int csize, void *debug, int nr_debug_entries, @@ -73,6 +75,6 @@ int jit_add_debug_info(Elf *e, uint64_t #endif /* The .text section is directly after the ELF header */ -#define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr) +#define GEN_ELF_TEXT_OFFSET round_up(sizeof(Elf_Ehdr) + sizeof(Elf_Phdr), 16) #endif