1 /* Interfaces for libdwelf. DWARF ELF Low-level Functions. 2 Copyright (C) 2014 Red Hat, Inc. 3 This file is part of elfutils. 4 5 This file is free software; you can redistribute it and/or modify 6 it under the terms of either 7 8 * the GNU Lesser General Public License as published by the Free 9 Software Foundation; either version 3 of the License, or (at 10 your option) any later version 11 12 or 13 14 * the GNU General Public License as published by the Free 15 Software Foundation; either version 2 of the License, or (at 16 your option) any later version 17 18 or both in parallel, as here. 19 20 elfutils is distributed in the hope that it will be useful, but 21 WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 General Public License for more details. 24 25 You should have received copies of the GNU General Public License and 26 the GNU Lesser General Public License along with this program. If 27 not, see <http://www.gnu.org/licenses/>. */ 28 29 #ifndef _LIBDWELF_H 30 #define _LIBDWELF_H 1 31 32 #include "libdw.h" 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* DWARF ELF Low-level Functions (dwelf). 39 Functions starting with dwelf_elf will take a (libelf) Elf object as 40 first argument and might set elf_errno on error. Functions starting 41 with dwelf_dwarf will take a (libdw) Dwarf object as first argument 42 and might set dwarf_errno on error. */ 43 44 /* Returns the name and the CRC32 of the separate debug file from the 45 .gnu_debuglink section if found in the ELF. Return NULL if the ELF 46 file didn't have a .gnu_debuglink section, had malformed data in the 47 section or some other error occured. */ 48 extern const char *dwelf_elf_gnu_debuglink (Elf *elf, GElf_Word *crc); 49 50 /* Returns the name and build ID from the .gnu_debugaltlink section if 51 found in the ELF. On success, pointers to the name and build ID 52 are written to *NAMEP and *BUILDID_P, and the positive length of 53 the build ID is returned. Returns 0 if the ELF lacks a 54 .gnu_debugaltlink section. Returns -1 in case of malformed data or 55 other errors. */ 56 extern ssize_t dwelf_dwarf_gnu_debugaltlink (Dwarf *dwarf, 57 const char **namep, 58 const void **build_idp); 59 60 /* Returns the build ID as found in a NT_GNU_BUILD_ID note from either 61 a SHT_NOTE section or from a PT_NOTE segment if the ELF file 62 doesn't contain any section headers. On success a pointer to the 63 build ID is written to *BUILDID_P, and the positive length of the 64 build ID is returned. Returns 0 if the ELF lacks a NT_GNU_BUILD_ID 65 note. Returns -1 in case of malformed data or other errors. */ 66 extern ssize_t dwelf_elf_gnu_build_id (Elf *elf, const void **build_idp); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif /* libdwelf.h */ 73