From: Adrian Hunter Date: Fri, 14 Oct 2022 17:09:04 +0000 (+0300) Subject: perf inject: Fix GEN_ELF_TEXT_OFFSET for jit X-Git-Tag: v6.1-rc5~151^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89b15d00527b7825ff19130ed83478e80e3fae99;p=platform%2Fkernel%2Flinux-starfive.git perf inject: Fix GEN_ELF_TEXT_OFFSET for jit 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 --- diff --git a/tools/perf/util/genelf.h b/tools/perf/util/genelf.h index b5c9095..6af062d 100644 --- 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, @@ -76,6 +78,6 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent #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