2 * common.h - Common internal operations performed by the module subsystem
4 * Created on: Aug 11, 2008
5 * Author: Stefan Bucur <stefanb@zytor.com>
13 #include <sys/module.h>
14 #include <linux/list.h>
18 // Performs an operation and jumps to a given label if an error occurs
19 #define CHECKED(res, expr, error) \
26 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
27 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
32 #define DBG_PRINT(fmt, args...) fprintf(stderr, "[ELF] " fmt, ##args)
34 #define DBG_PRINT(fmt, args...) // Expand to nothing
37 // User-space debugging routines
39 extern void print_elf_ehdr(Elf32_Ehdr
* ehdr
);
40 extern void print_elf_symbols(struct elf_module
*module
);
44 * Image files manipulation routines
47 extern int image_load(struct elf_module
*module
);
48 extern int image_unload(struct elf_module
*module
);
49 extern int image_read(void *buff
, size_t size
, struct elf_module
*module
);
50 extern int image_skip(size_t size
, struct elf_module
*module
);
51 extern int image_seek(Elf32_Off offset
, struct elf_module
*module
);
53 extern struct module_dep
*module_dep_alloc(struct elf_module
*module
);
55 extern int check_header_common(Elf32_Ehdr
* elf_hdr
);
57 extern int enforce_dependency(struct elf_module
*req
, struct elf_module
*dep
);
58 extern int clear_dependency(struct elf_module
*req
, struct elf_module
*dep
);
60 extern int check_symbols(struct elf_module
*module
);
62 #endif /* COMMON_H_ */