| .. | .. |
|---|
| 2 | 2 | #include <stdio.h> |
|---|
| 3 | 3 | #include <stdlib.h> |
|---|
| 4 | 4 | #include <stdarg.h> |
|---|
| 5 | +#include <stdbool.h> |
|---|
| 5 | 6 | #include <string.h> |
|---|
| 6 | 7 | #include <sys/types.h> |
|---|
| 7 | 8 | #include <sys/stat.h> |
|---|
| .. | .. |
|---|
| 109 | 110 | void |
|---|
| 110 | 111 | buf_write(struct buffer *buf, const char *s, int len); |
|---|
| 111 | 112 | |
|---|
| 113 | +struct namespace_list { |
|---|
| 114 | + struct namespace_list *next; |
|---|
| 115 | + char namespace[]; |
|---|
| 116 | +}; |
|---|
| 117 | + |
|---|
| 112 | 118 | struct module { |
|---|
| 113 | 119 | struct module *next; |
|---|
| 114 | | - const char *name; |
|---|
| 115 | 120 | int gpl_compatible; |
|---|
| 116 | 121 | struct symbol *unres; |
|---|
| 122 | + int from_dump; /* 1 if module was loaded from *.symvers */ |
|---|
| 123 | + int is_vmlinux; |
|---|
| 117 | 124 | int seen; |
|---|
| 118 | | - int skip; |
|---|
| 119 | 125 | int has_init; |
|---|
| 120 | 126 | int has_cleanup; |
|---|
| 121 | 127 | struct buffer dev_table_buf; |
|---|
| 122 | 128 | char srcversion[25]; |
|---|
| 123 | | - int is_dot_o; |
|---|
| 129 | + // Missing namespace dependencies |
|---|
| 130 | + struct namespace_list *missing_namespaces; |
|---|
| 131 | + // Actual imported namespaces |
|---|
| 132 | + struct namespace_list *imported_namespaces; |
|---|
| 133 | + char name[]; |
|---|
| 124 | 134 | }; |
|---|
| 125 | 135 | |
|---|
| 126 | 136 | struct elf_info { |
|---|
| 127 | | - unsigned long size; |
|---|
| 137 | + size_t size; |
|---|
| 128 | 138 | Elf_Ehdr *hdr; |
|---|
| 129 | 139 | Elf_Shdr *sechdrs; |
|---|
| 130 | 140 | Elf_Sym *symtab_start; |
|---|
| .. | .. |
|---|
| 171 | 181 | return info->symtab_shndx_start[sym - info->symtab_start]; |
|---|
| 172 | 182 | } |
|---|
| 173 | 183 | |
|---|
| 184 | +static inline bool strends(const char *str, const char *postfix) |
|---|
| 185 | +{ |
|---|
| 186 | + if (strlen(str) < strlen(postfix)) |
|---|
| 187 | + return false; |
|---|
| 188 | + |
|---|
| 189 | + return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; |
|---|
| 190 | +} |
|---|
| 191 | + |
|---|
| 174 | 192 | /* file2alias.c */ |
|---|
| 175 | 193 | extern unsigned int cross_build; |
|---|
| 176 | 194 | void handle_moddevtable(struct module *mod, struct elf_info *info, |
|---|
| .. | .. |
|---|
| 178 | 196 | void add_moddevtable(struct buffer *buf, struct module *mod); |
|---|
| 179 | 197 | |
|---|
| 180 | 198 | /* sumversion.c */ |
|---|
| 181 | | -void maybe_frob_rcs_version(const char *modfilename, |
|---|
| 182 | | - char *version, |
|---|
| 183 | | - void *modinfo, |
|---|
| 184 | | - unsigned long modinfo_offset); |
|---|
| 185 | 199 | void get_src_version(const char *modname, char sum[], unsigned sumlen); |
|---|
| 186 | 200 | |
|---|
| 187 | 201 | /* from modpost.c */ |
|---|
| 188 | | -void *grab_file(const char *filename, unsigned long *size); |
|---|
| 189 | | -char* get_next_line(unsigned long *pos, void *file, unsigned long size); |
|---|
| 190 | | -void release_file(void *file, unsigned long size); |
|---|
| 202 | +char *read_text_file(const char *filename); |
|---|
| 203 | +char *get_line(char **stringp); |
|---|
| 191 | 204 | |
|---|
| 192 | | -void fatal(const char *fmt, ...); |
|---|
| 193 | | -void warn(const char *fmt, ...); |
|---|
| 194 | | -void merror(const char *fmt, ...); |
|---|
| 205 | +enum loglevel { |
|---|
| 206 | + LOG_WARN, |
|---|
| 207 | + LOG_ERROR, |
|---|
| 208 | + LOG_FATAL |
|---|
| 209 | +}; |
|---|
| 210 | + |
|---|
| 211 | +void modpost_log(enum loglevel loglevel, const char *fmt, ...); |
|---|
| 212 | + |
|---|
| 213 | +/* |
|---|
| 214 | + * warn - show the given message, then let modpost continue running, still |
|---|
| 215 | + * allowing modpost to exit successfully. This should be used when |
|---|
| 216 | + * we still allow to generate vmlinux and modules. |
|---|
| 217 | + * |
|---|
| 218 | + * error - show the given message, then let modpost continue running, but fail |
|---|
| 219 | + * in the end. This should be used when we should stop building vmlinux |
|---|
| 220 | + * or modules, but we can continue running modpost to catch as many |
|---|
| 221 | + * issues as possible. |
|---|
| 222 | + * |
|---|
| 223 | + * fatal - show the given message, and bail out immediately. This should be |
|---|
| 224 | + * used when there is no point to continue running modpost. |
|---|
| 225 | + */ |
|---|
| 226 | +#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) |
|---|
| 227 | +#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) |
|---|
| 228 | +#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) |
|---|