summaryrefslogtreecommitdiff
path: root/src/format/elf/format_elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/elf/format_elf.c')
-rw-r--r--src/format/elf/format_elf.c126
1 files changed, 0 insertions, 126 deletions
diff --git a/src/format/elf/format_elf.c b/src/format/elf/format_elf.c
deleted file mode 100644
index 9f929fb..0000000
--- a/src/format/elf/format_elf.c
+++ /dev/null
@@ -1,126 +0,0 @@
-
-/* OpenIDA - Outil d'analyse de fichiers binaires
- * format_elf.c - support du format ELF
- *
- * 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 "elf.h"
-
-
-
-
-
-
-
-
-
-
-#include <ctype.h>
-#include <elf.h>
-#include <malloc.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-char *read_section_names(const uint8_t *content, Elf32_Off offset)
-{
- char *result;
- Elf32_Shdr section;
-
- result = NULL;
-
- memcpy(&section, &content[offset], sizeof(Elf32_Shdr));
-
- result = (char *)calloc(section.sh_size + 1, sizeof(char));
-
- memcpy(result, &content[section.sh_offset], section.sh_size);
-
- return result;
-
-}
-
-
-bool find_target_section(const uint8_t *content, const char *target, const char *names, Elf32_Off offset, Elf32_Shdr *data)
-{
- bool result;
- Elf32_Shdr section;
-
- result = false;
-
- memcpy(&section, &content[offset], sizeof(Elf32_Shdr));
-
- result = (strcmp(target, &names[section.sh_name]) == 0);
-
- if (result)
- {
- printf("section: %s (0x%08x)\n", &names[section.sh_name], section.sh_addr);
- *data = section;
- }
-
- return result;
-
-}
-
-
-
-bool find_text_data(const uint8_t *content, off_t *offset, off_t *size, uint64_t *voffset)
-{
- bool result;
- Elf32_Ehdr header;
- char *names;
- Elf32_Half i;
- Elf32_Shdr data;
-
- result = false;
-
- memcpy(&header, content, sizeof(Elf32_Ehdr));
-
- names = read_section_names(content, header.e_shoff + header.e_shentsize * header.e_shstrndx);
- if (names == NULL)
- {
- fprintf(stderr, "no section header string table\n");
- return NULL;
- }
-
- for (i = 0; i < header.e_shnum; i++)
- {
- if (i == header.e_shstrndx) continue;
-
- if (find_target_section(content, ".text", names, header.e_shoff + header.e_shentsize * i, &data))
- {
- printf("Find it !\n");
-
- *offset = data.sh_offset;
- *size = data.sh_size;
- *voffset = data.sh_addr;
-
- result = true;
-
- }
-
- }
-
- free(names);
-
- return result;
-
-}