hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/scripts/mod/modpost.h
....@@ -2,6 +2,7 @@
22 #include <stdio.h>
33 #include <stdlib.h>
44 #include <stdarg.h>
5
+#include <stdbool.h>
56 #include <string.h>
67 #include <sys/types.h>
78 #include <sys/stat.h>
....@@ -109,22 +110,31 @@
109110 void
110111 buf_write(struct buffer *buf, const char *s, int len);
111112
113
+struct namespace_list {
114
+ struct namespace_list *next;
115
+ char namespace[];
116
+};
117
+
112118 struct module {
113119 struct module *next;
114
- const char *name;
115120 int gpl_compatible;
116121 struct symbol *unres;
122
+ int from_dump; /* 1 if module was loaded from *.symvers */
123
+ int is_vmlinux;
117124 int seen;
118
- int skip;
119125 int has_init;
120126 int has_cleanup;
121127 struct buffer dev_table_buf;
122128 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[];
124134 };
125135
126136 struct elf_info {
127
- unsigned long size;
137
+ size_t size;
128138 Elf_Ehdr *hdr;
129139 Elf_Shdr *sechdrs;
130140 Elf_Sym *symtab_start;
....@@ -171,6 +181,14 @@
171181 return info->symtab_shndx_start[sym - info->symtab_start];
172182 }
173183
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
+
174192 /* file2alias.c */
175193 extern unsigned int cross_build;
176194 void handle_moddevtable(struct module *mod, struct elf_info *info,
....@@ -178,17 +196,33 @@
178196 void add_moddevtable(struct buffer *buf, struct module *mod);
179197
180198 /* sumversion.c */
181
-void maybe_frob_rcs_version(const char *modfilename,
182
- char *version,
183
- void *modinfo,
184
- unsigned long modinfo_offset);
185199 void get_src_version(const char *modname, char sum[], unsigned sumlen);
186200
187201 /* 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);
191204
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)