1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _CORKSCREW_SYMBOL_TABLE_H
18#define _CORKSCREW_SYMBOL_TABLE_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27typedef struct {
28    uintptr_t start;
29    uintptr_t end;
30    char* name;
31} symbol_t;
32
33typedef struct {
34    symbol_t* symbols;
35    size_t num_symbols;
36} symbol_table_t;
37
38/*
39 * Loads a symbol table from a given file.
40 * Returns NULL on error.
41 */
42symbol_table_t* load_symbol_table(const char* filename);
43
44/*
45 * Frees a symbol table.
46 */
47void free_symbol_table(symbol_table_t* table);
48
49/*
50 * Finds a symbol associated with an address in the symbol table.
51 * Returns NULL if not found.
52 */
53const symbol_t* find_symbol(const symbol_table_t* table, uintptr_t addr);
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif // _CORKSCREW_SYMBOL_TABLE_H
60