Debian Codegraph @

contrib/elfparser/elfparser.h

raw
1 /* Sysprof -- Sampling, systemwide CPU profiler
2 * Copyright 2006, 2007, Soeren Sandmann
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include <glib.h>
20
21 #ifndef NT_GNU_BUILD_ID
22 #define NT_GNU_BUILD_ID 3
23 #endif
24
25 typedef struct ElfSym ElfSym;
26 typedef struct ElfParser ElfParser;
27
28 ElfParser *elf_parser_new_from_data (const guchar *data,
29 gsize length);
30 ElfParser *elf_parser_new_from_mmap (GMappedFile *mapped_file,
31 GError **err);
32 ElfParser *elf_parser_new (const char *filename,
33 GError **err);
34 void elf_parser_free (ElfParser *parser);
35 const char *elf_parser_get_debug_link (ElfParser *parser,
36 guint32 *crc32);
37 const gchar *elf_parser_get_build_id (ElfParser *parser);
38 const guchar *elf_parser_get_eh_frame (ElfParser *parser);
39 const guchar *elf_parser_get_debug_frame (ElfParser *parser);
40 gulong elf_parser_get_text_offset (ElfParser *parser);
41
42
43 /* Lookup a symbol in the file.
44 *
45 * The symbol returned is const, so don't free it. It is valid until
46 * elf_parser_free() is called on the parser.
47 *
48 * The address should be given in "file coordinates". This means that
49 * if the file is mapped at address m and offset o, then an address a
50 * should be looked up as "a - (m - o)". (m - o) is where the start
51 * of the file would have been mapped, so a - (m - o) is the position
52 * in the file of a.
53 */
54 const ElfSym *elf_parser_lookup_symbol (ElfParser *parser,
55 gulong address);
56 guint32 elf_parser_get_crc32 (ElfParser *parser);
57 const char *elf_parser_get_sym_name (ElfParser *parser,
58 const ElfSym *sym);
59 gulong elf_parser_get_sym_address (ElfParser *parser,
60 const ElfSym *sym);
61 gboolean elf_parser_owns_symbol (ElfParser *parser,
62 const ElfSym *sym);
63 char *elf_demangle (const char *name);
64 void elf_parser_get_sym_address_range (ElfParser *parser,
65 const ElfSym *sym,
66 gulong *begin,
67 gulong *end);
68