linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH 6/7] perf inject: Fix GEN_ELF_TEXT_OFFSET for jit
Date: Fri, 14 Oct 2022 20:09:04 +0300	[thread overview]
Message-ID: <20221014170905.64069-7-adrian.hunter@intel.com> (raw)
In-Reply-To: <20221014170905.64069-1-adrian.hunter@intel.com>

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: babd04386b1d ("perf jit: Include program header in ELF files")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/genelf.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/genelf.h b/tools/perf/util/genelf.h
index b5c909546e3f..6af062d1c452 100644
--- a/tools/perf/util/genelf.h
+++ b/tools/perf/util/genelf.h
@@ -2,6 +2,8 @@
 #ifndef __GENELF_H__
 #define __GENELF_H__
 
+#include <linux/math.h>
+
 /* 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
-- 
2.25.1


  parent reply	other threads:[~2022-10-14 17:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 17:08 [PATCH 0/7] perf intel-pt: jitdump fix and test Adrian Hunter
2022-10-14 17:08 ` [PATCH 1/7] perf test: test_intel_pt.sh: Fix return checking again Adrian Hunter
2022-10-14 17:09 ` [PATCH 2/7] perf test: test_intel_pt.sh: Tidy some perf record options Adrian Hunter
2022-10-14 17:09 ` [PATCH 3/7] perf test: test_intel_pt.sh: Print a message when skipping kernel tracing Adrian Hunter
2022-10-14 17:09 ` [PATCH 4/7] perf test: test_intel_pt.sh: Tidy some alignment Adrian Hunter
2022-10-14 17:09 ` [PATCH 5/7] perf test: test_intel_pt.sh: Add jitdump test Adrian Hunter
2022-10-14 17:28   ` Arnaldo Carvalho de Melo
2022-10-14 17:32     ` Arnaldo Carvalho de Melo
2022-10-14 17:33       ` Arnaldo Carvalho de Melo
2022-10-14 17:35         ` Arnaldo Carvalho de Melo
2022-10-17 12:57     ` Adrian Hunter
2022-10-17 13:44       ` Arnaldo Carvalho de Melo
2022-10-17  9:35         ` Adrian Hunter
2022-10-14 17:09 ` Adrian Hunter [this message]
2022-10-14 17:09 ` [PATCH 7/7] perf test: test_intel_pt.sh: Add 9 tests Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221014170905.64069-7-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).