[PATCH] gprofng: Properly generate file offset for gmon.out
"H.J. Lu" <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <CAMe9rOpYCtZT3UzHLuhRtq0nCG443bwiygD-cUMtfAKt_HkEGQ@mail.gmail.com> |
When generating the map file for gmon.out, get the file offset from the filepos field of core_text_sect. This fixes FAIL: tmpdir/gp-gmon on Linux/x86-64. PR gprofng/34502 * src/gp-gmon.cc (gen_gmon_map): Get the file offset from the filepos field of core_text_sect. -- H.J.
0001-gprofng-Properly-generate-file-offset-for-gmon.out.patch
(text/x-patch, 1.4 KB)
From e309868d93544a242c933d71703dc173012782f3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Mon, 10 Aug 2026 11:54:24 +0800 Subject: [PATCH] gprofng: Properly generate file offset for gmon.out When generating the map file for gmon.out, get the file offset from the filepos field of core_text_sect. This fixes FAIL: tmpdir/gp-gmon on Linux/x86-64. PR gprofng/34502 * src/gp-gmon.cc (gen_gmon_map): Get the file offset from the filepos field of core_text_sect. Signed-off-by: H.J. Lu <[email protected]> --- gprofng/src/gp-gmon.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gprofng/src/gp-gmon.cc b/gprofng/src/gp-gmon.cc index f8a8adb7fc9..81fe48e2586 100644 --- a/gprofng/src/gp-gmon.cc +++ b/gprofng/src/gp-gmon.cc @@ -504,7 +504,7 @@ gen_gmon_map (char *name) bfd_vma loadaddr, vaddr = core_text_sect->vma; //lma? bfd_size_type msize = core_text_sect->size; int timestamp = 1; - int offset = 0; + int offset = core_text_sect->filepos; int check = -1; int modeflags = PROT_READ | PROT_EXEC; //0x05 char *new_file_path; @@ -522,6 +522,7 @@ gen_gmon_map (char *name) mpage = ~(page_size - 1); // Round down to page size alignment loadaddr = vaddr & mpage; + offset &= mpage; // Compensate for the alignment gain msize += vaddr - loadaddr; // Round up to a multiple of page size; -- 2.55.0