Releasing debian version 5.00+dfsg-1.
[syslinux-debian/hramrach.git] / com32 / lib / sys / module / common.h
blob54f0ec4b64960431383a04e22783d0dcfbff63fa
1 /*
2 * common.h - Common internal operations performed by the module subsystem
4 * Created on: Aug 11, 2008
5 * Author: Stefan Bucur <stefanb@zytor.com>
6 */
8 #ifndef COMMON_H_
9 #define COMMON_H_
11 #include <stdio.h>
13 #include <sys/module.h>
14 #include <linux/list.h>
16 #include "elfutils.h"
19 // Performs an operation and jumps to a given label if an error occurs
20 #define CHECKED(res, expr, error) \
21 do { \
22 (res) = (expr); \
23 if ((res) < 0) \
24 goto error; \
25 } while (0)
27 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
28 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
30 static inline Elf32_Sym *symbol_get_entry(struct elf_module *module, int entry)
32 char *sym_table = (char *)module->sym_table;
33 int index = entry * module->syment_size;
35 return (Elf32_Sym *)(sym_table + index);
38 //#define ELF_DEBUG
40 #ifdef ELF_DEBUG
41 #define DBG_PRINT(fmt, args...) fprintf(stderr, "[ELF] " fmt, ##args)
42 #else
43 #define DBG_PRINT(fmt, args...) // Expand to nothing
44 #endif
46 // User-space debugging routines
47 #ifdef ELF_DEBUG
48 extern void print_elf_ehdr(Elf32_Ehdr *ehdr);
49 extern void print_elf_symbols(struct elf_module *module);
50 #endif //ELF_DEBUG
54 * Image files manipulation routines
57 extern int image_load(struct elf_module *module);
58 extern int image_unload(struct elf_module *module);
59 extern int image_read(void *buff, size_t size, struct elf_module *module);
60 extern int image_skip(size_t size, struct elf_module *module);
61 extern int image_seek(Elf32_Off offset, struct elf_module *module);
63 extern struct module_dep *module_dep_alloc(struct elf_module *module);
65 extern int check_header_common(Elf32_Ehdr *elf_hdr);
67 extern int enforce_dependency(struct elf_module *req, struct elf_module *dep);
68 extern int clear_dependency(struct elf_module *req, struct elf_module *dep);
70 extern int check_symbols(struct elf_module *module);
73 #endif /* COMMON_H_ */