From 5389aa19033153c09556d1362a8b8a56abccb8f5 Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Tue, 16 Feb 2010 10:38:35 -0800 Subject: Merge memory checking from sandbox Change-id: Ibce845d0 --- elff/elff_api.cc | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 elff/elff_api.cc (limited to 'elff/elff_api.cc') diff --git a/elff/elff_api.cc b/elff/elff_api.cc new file mode 100644 index 0000000..46b2ad1 --- /dev/null +++ b/elff/elff_api.cc @@ -0,0 +1,84 @@ +/* Copyright (C) 2007-2010 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ + +/* + * Contains implementation of routines that encapsulte an API for parsing + * an ELF file containing debugging information in DWARF format. + */ + +#include "elff_api.h" +#include "elf_file.h" +#include "dwarf_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +ELFF_HANDLE +elff_init(const char* elf_file_path) +{ + ElfFile* elf_file = ElfFile::Create(elf_file_path); + return reinterpret_cast(elf_file); +} + +void +elff_close(ELFF_HANDLE handle) +{ + if (handle != NULL) { + delete reinterpret_cast(handle); + } +} + +int +elff_is_exec(ELFF_HANDLE handle) +{ + assert(handle != NULL); + if (handle == NULL) { + _set_errno(EINVAL); + return -1; + } + return reinterpret_cast(handle)->is_exec(); +} + +int +elff_get_pc_address_info(ELFF_HANDLE handle, + uint64_t address, + Elf_AddressInfo* address_info) +{ + assert(handle != NULL && address_info != NULL); + if (handle == NULL || address_info == NULL) { + _set_errno(EINVAL); + return -1; + } + + if (reinterpret_cast(handle)->get_pc_address_info(address, + address_info)) { + return 0; + } else { + return -1; + } +} + +void +elff_free_pc_address_info(ELFF_HANDLE handle, Elf_AddressInfo* address_info) +{ + assert(handle != NULL && address_info != NULL); + if (handle == NULL || address_info == NULL) { + return; + } + reinterpret_cast(handle)->free_pc_address_info(address_info); +} + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + -- cgit v1.1