From f2e33c3268db9adf8e57e991676ed0d5ac74e8a8 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 23 Aug 2021 08:11:54 +0530 Subject: mtrace: Fix output with PIE and ASLR [BZ #22716] Record only the relative address of the caller in mtrace file. Use LD_TRACE_PRELINKING to get the executable as well as binary vs executable load offsets so that we may compute a base to add to the relative address in the mtrace file. This allows us to get a valid address to pass to addr2line in all cases. Fixes BZ #22716. Co-authored-by: John Ogness Reviewed-by: Andreas Schwab Reviewed-by: DJ Delorie --- malloc/mtrace-impl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'malloc/mtrace-impl.c') diff --git a/malloc/mtrace-impl.c b/malloc/mtrace-impl.c index 83008ca18f..f5f19c265c 100644 --- a/malloc/mtrace-impl.c +++ b/malloc/mtrace-impl.c @@ -65,9 +65,9 @@ tr_where (const void *caller, Dl_info *info) offset); } - fprintf (mallstream, "@ %s%s%s[%p] ", info->dli_fname ? : "", - info->dli_fname ? ":" : "", - buf, caller); + fprintf (mallstream, "@ %s%s%s[0x%" PRIxPTR "] ", + info->dli_fname ? : "", info->dli_fname ? ":" : "", buf, + caller - info->dli_fbase); } else fprintf (mallstream, "@ [%p] ", caller); -- cgit 1.4.1