Add memtest support.
[syslinux-debian/hramrach.git] / com32 / lib / sys / module / elfutils.h
blob91bdcb3f2385fa83969cc7d12a886cf42279db68
1 #ifndef ELF_UTILS_H_
2 #define ELF_UTILS_H_
4 #include <elf.h>
5 #include <stdlib.h>
6 #include <sys/module.h>
8 /**
9 * elf_get_header - Returns a pointer to the ELF header structure.
10 * @elf_image: pointer to the ELF file image in memory
12 static inline Elf_Ehdr *elf_get_header(void *elf_image) {
13 return (Elf_Ehdr*)elf_image;
16 /**
17 * elf_get_pht - Returns a pointer to the first entry in the PHT.
18 * @elf_image: pointer to the ELF file image in memory
20 static inline Elf_Phdr *elf_get_pht(void *elf_image) {
21 Elf_Ehdr *elf_hdr = elf_get_header(elf_image);
23 return (Elf_Phdr*)((Elf_Off)elf_hdr + elf_hdr->e_phoff);
27 /**
28 * elf_get_ph - Returns the element with the given index in the PTH
29 * @elf_image: pointer to the ELF file image in memory
30 * @index: the index of the PHT entry to look for
32 static inline Elf_Phdr *elf_get_ph(void *elf_image, int index) {
33 Elf_Phdr *elf_pht = elf_get_pht(elf_image);
34 Elf_Ehdr *elf_hdr = elf_get_header(elf_image);
36 return (Elf_Phdr*)((Elf_Off)elf_pht + index * elf_hdr->e_phentsize);
39 /**
40 * elf_hash - Returns the index in a SysV hash table for the symbol name.
41 * @name: the name of the symbol to look for
43 extern unsigned long elf_hash(const unsigned char *name);
45 /**
46 * elf_gnu_hash - Returns the index in a GNU hash table for the symbol name.
47 * @name: the name of the symbol to look for
49 extern unsigned long elf_gnu_hash(const unsigned char *name);
51 /**
52 * elf_malloc - Allocates memory to be used by ELF module contents.
53 * @memptr: pointer to a variable to hold the address of the allocated block.
54 * @alignment: alignment constraints of the block
55 * @size: the required size of the block
57 extern int elf_malloc(void **memptr, size_t alignment, size_t size);
59 /**
60 * elf_free - Releases memory previously allocated by elf_malloc.
61 * @memptr: the address of the allocated block
63 extern void elf_free(char *memptr);
65 #endif /*ELF_UTILS_H_*/