blob: ba498f945f4b23585f242bead34c21f1a3112579 [file] [log] [blame]
mostang.com!davidmb39b4342003-04-24 20:45:07 +00001/* libunwind - a platform-independent unwind library
hp.com!davidm07b01ad2005-05-20 09:48:08 +00002 Copyright (C) 2003-2005 Hewlett-Packard Co
mostang.com!davidmb39b4342003-04-24 20:45:07 +00003 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5This file is part of libunwind.
6
7Permission is hereby granted, free of charge, to any person obtaining
8a copy of this software and associated documentation files (the
9"Software"), to deal in the Software without restriction, including
10without limitation the rights to use, copy, modify, merge, publish,
11distribute, sublicense, and/or sell copies of the Software, and to
12permit persons to whom the Software is furnished to do so, subject to
13the following conditions:
14
15The above copyright notice and this permission notice shall be
16included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
25
mostang.com!davidmb39b4342003-04-24 20:45:07 +000026#include <dlfcn.h>
Arun Sharma1787a2f2010-05-15 12:14:09 -070027#include <string.h>
mostang.com!davidmb39b4342003-04-24 20:45:07 +000028#include <unistd.h>
29
hp.com!davidm07b01ad2005-05-20 09:48:08 +000030#include "libunwind_i.h"
mostang.com!davidmb39b4342003-04-24 20:45:07 +000031
32#include "elf64.h"
33
34HIDDEN int
35tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
Arun Sharma1787a2f2010-05-15 12:14:09 -070036 unsigned long *segbase, unsigned long *mapoff,
Joel Brobeckerea7160a2011-06-15 20:07:09 -040037 char *path, size_t pathlen)
mostang.com!davidmb39b4342003-04-24 20:45:07 +000038{
39 struct load_module_desc lmd;
Arun Sharma1787a2f2010-05-15 12:14:09 -070040 const char *path2;
mostang.com!davidmb39b4342003-04-24 20:45:07 +000041
42 if (pid != getpid ())
43 {
44 printf ("%s: remote case not implemented yet\n", __FUNCTION__);
45 return -UNW_ENOINFO;
46 }
47
48 if (!dlmodinfo (ip, &lmd, sizeof (lmd), NULL, 0, 0))
49 return -UNW_ENOINFO;
50
51 *segbase = lmd.text_base;
52 *mapoff = 0; /* XXX fix me? */
53
Arun Sharma1787a2f2010-05-15 12:14:09 -070054 path2 = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
55 if (!path2)
mostang.com!davidmb39b4342003-04-24 20:45:07 +000056 return -UNW_ENOINFO;
Arun Sharma1787a2f2010-05-15 12:14:09 -070057 if (path)
58 {
59 strncpy(path, path2, pathlen);
60 path[pathlen - 1] = '\0';
61 if (strcmp(path, path2) != 0)
62 Debug(1, "buffer size (%d) not big enough to hold path\n", pathlen);
63 }
hp.com!davidmc67d3452004-01-30 00:01:24 +000064 Debug(1, "segbase=%lx, mapoff=%lx, path=%s\n", *segbase, *mapoff, path);
mostang.com!davidmb39b4342003-04-24 20:45:07 +000065
66 return elf_map_image (ei, path);
67}
Christopher Ferris7d46a212013-11-14 14:03:33 -080068
69struct map_info *
70maps_create_list(pid_t pid)
71{
72 return NULL;
73}
74
75int maps_is_readable(struct map_info *map_list, unw_word_t addr)
76{
77 return true;
78}
79
80int maps_is_writable(struct map_info *map_list, unw_word_t addr)
81{
82 return true;
83}