|
Packit |
032894 |
/* Common interface for libebl modules.
|
|
Packit |
032894 |
Copyright (C) 2000, 2001, 2002, 2003, 2005, 2013, 2014 Red Hat, Inc.
|
|
Packit |
032894 |
This file is part of elfutils.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
This file is free software; you can redistribute it and/or modify
|
|
Packit |
032894 |
it under the terms of either
|
|
Packit |
032894 |
|
|
Packit |
032894 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit |
032894 |
Software Foundation; either version 3 of the License, or (at
|
|
Packit |
032894 |
your option) any later version
|
|
Packit |
032894 |
|
|
Packit |
032894 |
or
|
|
Packit |
032894 |
|
|
Packit |
032894 |
* the GNU General Public License as published by the Free
|
|
Packit |
032894 |
Software Foundation; either version 2 of the License, or (at
|
|
Packit |
032894 |
your option) any later version
|
|
Packit |
032894 |
|
|
Packit |
032894 |
or both in parallel, as here.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit |
032894 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
032894 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
032894 |
General Public License for more details.
|
|
Packit |
032894 |
|
|
Packit |
032894 |
You should have received copies of the GNU General Public License and
|
|
Packit |
032894 |
the GNU Lesser General Public License along with this program. If
|
|
Packit |
032894 |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#ifndef _LIBEBL_CPU_H
|
|
Packit |
032894 |
#define _LIBEBL_CPU_H 1
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#include <dwarf.h>
|
|
Packit |
032894 |
#include <libeblP.h>
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#define EBLHOOK(name) EBLHOOK_1(BACKEND, name)
|
|
Packit |
032894 |
#define EBLHOOK_1(a, b) EBLHOOK_2(a, b)
|
|
Packit |
032894 |
#define EBLHOOK_2(a, b) a##b
|
|
Packit |
032894 |
|
|
Packit |
032894 |
/* Constructor. */
|
|
Packit |
032894 |
extern const char *EBLHOOK(init) (Elf *elf, GElf_Half machine,
|
|
Packit |
032894 |
Ebl *eh, size_t ehlen);
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#include "ebl-hooks.h"
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#define HOOK(eh, name) eh->name = EBLHOOK(name)
|
|
Packit |
032894 |
|
|
Packit |
032894 |
extern bool (*generic_debugscn_p) (const char *) attribute_hidden;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
/* Helper for retval. Return dwarf_tag (die), but calls return -1
|
|
Packit |
032894 |
if there where previous errors that leave die NULL. */
|
|
Packit |
032894 |
#define DWARF_TAG_OR_RETURN(die) \
|
|
Packit |
032894 |
({ Dwarf_Die *_die = (die); \
|
|
Packit |
032894 |
if (_die == NULL) return -1; \
|
|
Packit |
032894 |
dwarf_tag (_die); })
|
|
Packit |
032894 |
|
|
Packit |
032894 |
/* Get a type die corresponding to DIE. Peel CV qualifiers off
|
|
Packit |
032894 |
it. */
|
|
Packit |
032894 |
static inline int
|
|
Packit |
032894 |
dwarf_peeled_die_type (Dwarf_Die *die, Dwarf_Die *result)
|
|
Packit |
032894 |
{
|
|
Packit |
032894 |
Dwarf_Attribute attr_mem;
|
|
Packit |
032894 |
Dwarf_Attribute *attr = dwarf_attr_integrate (die, DW_AT_type, &attr_mem);
|
|
Packit |
032894 |
if (attr == NULL)
|
|
Packit |
032894 |
/* The function has no return value, like a `void' function in C. */
|
|
Packit |
032894 |
return 0;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (dwarf_formref_die (attr, result) == NULL)
|
|
Packit |
032894 |
return -1;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
if (dwarf_peel_type (result, result) != 0)
|
|
Packit |
032894 |
return -1;
|
|
Packit |
032894 |
|
|
Packit |
032894 |
return DWARF_TAG_OR_RETURN (result);
|
|
Packit |
032894 |
}
|
|
Packit |
032894 |
|
|
Packit |
032894 |
#endif /* libebl_CPU.h */
|