Merge branch 'master' of ../module-init-tools_alan
[mit.git] / elfops.h
blob0fb5167e16e38420af971103440661ec7408ef18
1 #ifndef MODINITTOOLS_MODULEOPS_H
2 #define MODINITTOOLS_MODULEOPS_H
3 #include <stdio.h>
4 #include <stdint.h>
5 #include "logging.h"
7 /* All the icky stuff to do with manipulating 64 and 32-bit modules
8 belongs here. */
9 struct modver_info32
11 uint32_t crc;
12 char name[64 - sizeof(uint32_t)];
15 struct modver_info64
17 uint64_t crc;
18 char name[64 - sizeof(uint64_t)];
21 struct elf_file
23 char *pathname;
25 /* File operations */
26 struct module_ops *ops;
28 /* Convert endian? */
29 int conv;
31 /* File contents and length. */
32 void *data;
33 unsigned long len;
36 /* Tables extracted from module by ops->fetch_tables(). */
37 struct module_tables
39 unsigned int pci_size;
40 void *pci_table;
41 unsigned int usb_size;
42 void *usb_table;
43 unsigned int ieee1394_size;
44 void *ieee1394_table;
45 unsigned int ccw_size;
46 void *ccw_table;
47 unsigned int pnp_size;
48 void *pnp_table;
49 unsigned int pnp_card_size;
50 unsigned int pnp_card_offset;
51 void *pnp_card_table;
52 unsigned int input_size;
53 void *input_table;
54 unsigned int input_table_size;
55 unsigned int serio_size;
56 void *serio_table;
57 unsigned int of_size;
58 void *of_table;
61 struct module_ops
63 void *(*load_section)(struct elf_file *module,
64 const char *secname, unsigned long *secsize);
65 struct string_table *(*load_strings)(struct elf_file *module,
66 const char *secname, struct string_table *tbl, errfn_t error);
67 struct string_table *(*load_symbols)(struct elf_file *module,
68 uint64_t **versions);
69 struct string_table *(*load_dep_syms)(struct elf_file *module,
70 struct string_table **types, uint64_t **versions);
71 void (*fetch_tables)(struct elf_file *module,
72 struct module_tables *tables);
73 char *(*get_aliases)(struct elf_file *module, unsigned long *size);
74 char *(*get_modinfo)(struct elf_file *module, unsigned long *size);
75 void (*strip_section)(struct elf_file *module, const char *secname);
76 int (*dump_modvers)(struct elf_file *module);
79 extern struct module_ops mod_ops32, mod_ops64;
81 struct elf_file *grab_elf_file(const char *pathname);
82 struct elf_file *grab_elf_file_fd(const char *pathname, int fd);
83 void release_elf_file(struct elf_file *file);
85 #endif /* MODINITTOOLS_MODULEOPS_H */