summaryrefslogtreecommitdiff
path: root/libdwfl/dwfl_module_getdwarf.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2014-02-22 21:06:49 +0100
committerJan Kratochvil <jan.kratochvil@redhat.com>2014-02-22 22:05:04 +0100
commit25a2c8477e8bc165a7c78719e7f0f30514abfc57 (patch)
tree620ec2a62487b104792212527395ed552f29d2e9 /libdwfl/dwfl_module_getdwarf.c
parent112bcc0bebc8c3499acc67d04f292b3908e4fbcc (diff)
downloadelfutils-25a2c8477e8bc165a7c78719e7f0f30514abfc57.tar.gz
Access deleted files by /dev/PID/mem.jankratochvil/devmem
libdwfl/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Access deleted files by /dev/PID/mem. * dwfl_module.c (dwfl_report_module_pid): New function. * dwfl_module_getdwarf.c (open_elf): Call __libdw_open_file_at_offset. * libdwfl.h (dwfl_report_module_pid): New declaration. * libdwflP.h (struct Dwfl_Module): New field pid. (INTDECL (dwfl_report_module_pid)): New. * linux-proc-maps.c (proc_maps_report): New variable first_high. (proc_maps_report) (report): Possibly call dwfl_report_module_pid. tests/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Access deleted files by /dev/PID/mem. * Makefile.am (check_PROGRAMS): Add deleted and deleted-lib.so. (TESTS, EXTRA_DIST): Add run-deleted.sh. (deleted_LDADD, deleted_lib_so_LDFLAGS, deleted_lib_so_CFLAGS): New. * deleted-lib.c: New file. * deleted.c: New file. * run-deleted.sh: New file. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Diffstat (limited to 'libdwfl/dwfl_module_getdwarf.c')
-rw-r--r--libdwfl/dwfl_module_getdwarf.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index c4bd7395..d667513f 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -45,6 +45,16 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
set it with an open failure below. */
errno = 0;
+ off_t start_offset = 0;
+ size_t maximum_size = ~((size_t) 0);
+ if (mod->pid != 0 && file == &mod->main)
+ {
+ if (asprintf (&file->name, "/proc/%d/mem", mod->pid) < 0)
+ return CBFAIL;
+ start_offset = mod->low_addr;
+ maximum_size = mod->high_addr - mod->low_addr;
+ }
+
/* If there was a pre-primed file name left that the callback left
behind, try to open that file name. */
if (file->fd < 0 && file->name != NULL)
@@ -53,7 +63,10 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
if (file->fd < 0)
return CBFAIL;
- Dwfl_Error error = __libdw_open_file (&file->fd, &file->elf, true, false);
+ Dwfl_Error error = __libdw_open_file_at_offset (&file->fd, &file->elf,
+ start_offset,
+ maximum_size,
+ true, false);
if (error != DWFL_E_NOERROR)
return error;
}