Skip to content

Commit 89b15d0

Browse files
ahunter6acmel
authored andcommitted
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: babd043 ("perf jit: Include program header in ELF files") Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Lieven Hey <lieven.hey@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20221014170905.64069-7-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 973db24 commit 89b15d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/util/genelf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef __GENELF_H__
33
#define __GENELF_H__
44

5+
#include <linux/math.h>
6+
57
/* genelf.c */
68
int jit_write_elf(int fd, uint64_t code_addr, const char *sym,
79
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
7678
#endif
7779

7880
/* The .text section is directly after the ELF header */
79-
#define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr)
81+
#define GEN_ELF_TEXT_OFFSET round_up(sizeof(Elf_Ehdr) + sizeof(Elf_Phdr), 16)
8082

8183
#endif

0 commit comments

Comments
 (0)