From 0ca198f1f90071a054287c204a3fd1b4ea315e18 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 11 Dec 2017 02:32:26 +0100 Subject: Record executable entry for PIE core dumps * hurd/process.defs (proc_set_entry, proc_get_entry): New RPCs. * hurd/process_reply.defs: Add skips for proc_set_entry, proc_get_entry. * hurd/process_request.defs: Likewise. * exec/exec.c (do_exec): Call proc_set_entry. * proc/proc.h (proc): Add p_entry field. * proc/mgt.c (S_proc_set_entry, S_proc_get_entry): New RPC implementations. * exec/elfcore.c (dump_core): Add at_entry note, call proc_get_entry to get it, and write it with WRITE_NOTE. --- exec/elfcore.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'exec/elfcore.c') diff --git a/exec/elfcore.c b/exec/elfcore.c index 12ecf34f..2dd499bf 100644 --- a/exec/elfcore.c +++ b/exec/elfcore.c @@ -331,6 +331,7 @@ dump_core (task_t task, file_t file, off_t corelimit, { DEFINE_NOTE (psinfo_t) psinfo; DEFINE_NOTE (pstatus_t) pstatus; + DEFINE_NOTE (ElfW(auxv_t)) at_entry; int flags = PI_FETCH_TASKINFO | PI_FETCH_THREADS | PI_FETCH_THREAD_BASIC; char *waits = 0; mach_msg_type_number_t num_waits = 0; @@ -410,6 +411,18 @@ dump_core (task_t task, file_t file, off_t corelimit, err = proc_get_arg_locations (proc, &psinfo.data.pr_argv, &psinfo.data.pr_envp); + if (err == 0) + { + /* Write position of executable. */ + vm_address_t addr; + err = proc_get_entry (proc, &addr); + if (err == 0) + { + at_entry.data.a_type = AT_ENTRY; + at_entry.data.a_un.a_val = addr; + err = WRITE_NOTE (NT_AUXV, at_entry); + } + } mach_port_deallocate (mach_task_self (), proc); } { -- cgit v1.2.3