diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-08-08 09:28:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-08-08 09:28:16 (GMT) |
commit | 904476ddf621d9513bf90a3fa396d2e6c1ea2952 (patch) | |
tree | f8966baa2ea80d2c2068a85b24ead1e651d17dc9 /src/format/dwarf | |
parent | 0153acaaf41e97477f6c484a92c2dd46f5122300 (diff) |
Prepared to handle the DWARF debug format.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@15 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/dwarf')
-rw-r--r-- | src/format/dwarf/Makefile.am | 15 | ||||
-rw-r--r-- | src/format/dwarf/abbrev.c | 93 | ||||
-rw-r--r-- | src/format/dwarf/abbrev.h | 41 | ||||
-rw-r--r-- | src/format/dwarf/d_dwarf.c | 75 | ||||
-rw-r--r-- | src/format/dwarf/d_dwarf.h | 48 | ||||
-rw-r--r-- | src/format/dwarf/dwarf-int.h | 46 |
6 files changed, 318 insertions, 0 deletions
diff --git a/src/format/dwarf/Makefile.am b/src/format/dwarf/Makefile.am new file mode 100644 index 0000000..d9a3ca6 --- /dev/null +++ b/src/format/dwarf/Makefile.am @@ -0,0 +1,15 @@ + +lib_LIBRARIES = libformatdwarf.a + +libformatdwarf_a_SOURCES = \ + abbrev.h abbrev.c \ + d_dwarf.h d_dwarf.c + +libformatdwarf_a_CFLAGS = $(AM_CFLAGS) + + +INCLUDES = + +AM_CPPFLAGS = + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) diff --git a/src/format/dwarf/abbrev.c b/src/format/dwarf/abbrev.c new file mode 100644 index 0000000..8cf5dcd --- /dev/null +++ b/src/format/dwarf/abbrev.c @@ -0,0 +1,93 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * abbrev.c - manipulation des abréviation DWARF + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "abbrev.h" + + +#include <malloc.h> + + +#include "dwarf-int.h" + + + + + + + + +/****************************************************************************** +* * +* Paramètres : format = informations de débogage à compléter. * +* * +* Description : Charge les abréviations trouvés pour un DWARF. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool load_dwarf_abbreviations(dwarf_format *format) +{ + + + + + + off_t offset; + off_t size; + + bool test; + + int i; + + + printf("Searching...\n"); + + + test = find_exe_section(DBG_FORMAT(format)->e_format, ".debug_abbrev", &offset, &size, NULL); + + + + + printf(" -> offset=%d size=%d\n", offset, size); + + + for (i = 0; i < size; i++) + { + if (i % 10 == 0) printf("\n"); + printf("0x%02hhx ", DBG_FORMAT(format)->content[offset + i]); + } + + printf("\n"); + + + + + + + + +} + diff --git a/src/format/dwarf/abbrev.h b/src/format/dwarf/abbrev.h new file mode 100644 index 0000000..a949be9 --- /dev/null +++ b/src/format/dwarf/abbrev.h @@ -0,0 +1,41 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * abbrev.h - prototypes pour la manipulation des abréviation DWARF + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _FORMAT_DWARF_ABBREV_H +#define _FORMAT_DWARF_ABBREV_H + + +#include <stdbool.h> + + +#include "d_dwarf.h" + + + +/* Charge les abréviations trouvés pour un DWARF. */ +bool load_dwarf_abbreviations(dwarf_format *); + + + + +#endif /* _FORMAT_DWARF_ABBREV_H */ diff --git a/src/format/dwarf/d_dwarf.c b/src/format/dwarf/d_dwarf.c new file mode 100644 index 0000000..7537e34 --- /dev/null +++ b/src/format/dwarf/d_dwarf.c @@ -0,0 +1,75 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * d_dwarf.c - support du format DWARF + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "d_dwarf.h" + + +#include <malloc.h> + + +#include "abbrev.h" +#include "dwarf-int.h" + + + + + + + + +/****************************************************************************** +* * +* Paramètres : content = contenu binaire à parcourir. * +* length = taille du contenu en question. * +* e_format = gestionnaire global (partie exécutable). * +* * +* Description : Prend en charge un nouveau DWARF. * +* * +* Retour : Adresse de la structure mise en place ou NULL en cas d'échec.* +* * +* Remarques : - * +* * +******************************************************************************/ + +dwarf_format *load_dwarf(const uint8_t *content, off_t length, exe_format *e_format) +{ + dwarf_format *result; /* Structure à retourner */ + bool test; /* Bilan d'une initialisation */ + + result = (dwarf_format *)calloc(1, sizeof(dwarf_format)); + + DBG_FORMAT(result)->content = content; + DBG_FORMAT(result)->length = length; + + DBG_FORMAT(result)->e_format = e_format; + + + test = load_dwarf_abbreviations(result); + + + return result; + +} + + + diff --git a/src/format/dwarf/d_dwarf.h b/src/format/dwarf/d_dwarf.h new file mode 100644 index 0000000..d432d5a --- /dev/null +++ b/src/format/dwarf/d_dwarf.h @@ -0,0 +1,48 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * d_dwarf.h - prototypes pour le support du format DWARF + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _FORMAT_DWARF_DWARF_H +#define _FORMAT_DWARF_DWARF_H + + +#include <stdint.h> +#include <sys/types.h> + + +#include "../exe_format.h" + + + +/* Description du format DWARF */ +typedef struct _dwarf_format dwarf_format; + + + +/* Prend en charge un nouveau DWARF. */ +dwarf_format *load_dwarf(const uint8_t *, off_t, exe_format *); + + + + + +#endif /* _FORMAT_DWARF_DWARF_H */ diff --git a/src/format/dwarf/dwarf-int.h b/src/format/dwarf/dwarf-int.h new file mode 100644 index 0000000..e3bb212 --- /dev/null +++ b/src/format/dwarf/dwarf-int.h @@ -0,0 +1,46 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * dwarf-int.h - prototypes pour les structures internes du format DWARF + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _FORMAT_DWARF_DWARF_INT_H +#define _FORMAT_DWARF_DWARF_INT_H + + + + +#include "../dbg_format-int.h" + + + +/* Description du format DWARF */ +struct _dwarf_format +{ + dbg_format dummy; /* A laisser en premier */ + + + +}; + + + + +#endif /* _FORMAT_DWARF_DWARF_INT_H */ |