initial commit
[surgeon.git] / elf_utils.h
blobe1941252949cdba88772dcfebb2f5d359108bc59
1 /*
2 * Copyright (C) 2010 gonzoj
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ELF_UTILS_H_
19 #define ELF_UTILS_H_
21 #include <linux/elf.h>
22 #include <string.h>
24 #include "types.h"
26 extern pid_t pid;
28 int
29 elf_is_valid(vaddr_t);
31 int
32 elf_read(vaddr_t, void *, size_t);
34 #define elf_read_ehdr(addr, ehdr) elf_read(addr, &ehdr, sizeof(Elf32_Ehdr))
36 #define elf_read_phdr(addr, phdr) elf_read(addr, &phdr, sizeof(Elf32_Phdr))
38 #define elf_read_shdr(addr, shdr) elf_read(addr, &shdr, sizeof(Elf32_Shdr))
40 #define elf_read_dyn(addr, dyn) elf_read(addr, &dyn, sizeof(Elf32_Dyn))
42 #define elf_read_sym(addr, sym) elf_read(addr, &sym, sizeof(Elf32_Sym))
44 char *
45 elf_read_string(vaddr_t);
47 void
48 elf_dump_ehdr(Elf32_Ehdr);
50 void
51 elf_dump_phdr(Elf32_Phdr);
53 void
54 elf_dump_shdr(Elf32_Shdr);
56 void
57 elf_dump_dyn(Elf32_Dyn);
59 void
60 elf_dump_sym(Elf32_Sym);
62 #endif /* ELF_UTILS_H_ */