History

module: Account for the build time module name mangling

Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle the module name with s/-/_/g. Since this happens late in the build, only the kernel needs to bother with this, the modpost tool still sees the original name.

Peter Zijlstra committed 1 year ago

Commit 0267cbf1 parent 754f8731 file · +25 −1Browse files

Showing the changes to kernel/module (1 of 1 file). Show all

Unified · Split

kernel/module/main.c+25−1
@@ -169,6 +169,30 @@ static inline void add_taint_module(struct module *mod, unsigned flag, · 168 unmodified lines
169169 set_bit(flag, &mod->taints);
170170 }
171171
172+/*
173+ * Like strncmp(), except s/-/_/g as per scripts/Makefile.lib:name-fix-token rule.
174+ */
175+static int mod_strncmp(const char *str_a, const char *str_b, size_t n)
176+{
177+ for (int i = 0; i < n; i++) {
178+ char a = str_a[i];
179+ char b = str_b[i];
180+ int d;
181+
182+ if (a == '-') a = '_';
183+ if (b == '-') b = '_';
184+
185+ d = a - b;
186+ if (d)
187+ return d;
188+
189+ if (!a)
190+ break;
191+ }
192+
193+ return 0;
194+}
195+
172196 /*
173197 * A thread that wants to hold a reference to a module only while it
174198 * is running can call this to safely exit.
@@ -1116,7 +1140,7 @@ static bool verify_module_namespace(const char *namespace, const char *modname) · 941 unmodified lines
11161140 if (*sep)
11171141 sep++;
11181142
1119− if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
1143+ if (mod_strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
11201144 return true;
11211145 }
11221146

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t