lkml.org 
[lkml]   [2022]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 24/27] modpost: generate linker script to collect symbol versions
Date
Merge version CRCs per vmlinux or per module.

These linker scripts will be fed to the final link stage.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

.gitignore | 1 +
Makefile | 1 +
scripts/mod/modpost.c | 27 +++++++++++++++++++++++++++
3 files changed, 29 insertions(+)

diff --git a/.gitignore b/.gitignore
index 265959544978..f9dad6b917e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@
*.so.dbg
*.su
*.symtypes
+*.symver.lds
*.symversions
*.tab.[ch]
*.tar
diff --git a/Makefile b/Makefile
index 235d68fa1470..0779db3d1c0c 100644
--- a/Makefile
+++ b/Makefile
@@ -1859,6 +1859,7 @@ clean: $(clean-dirs)
-o -name '*.c.[012]*.*' \
-o -name '*.ll' \
-o -name '*.gcno' \
+ -o -name '*.symver.lds' \
-o -name '*.*.symversions' \) -type f -print | xargs rm -f

# Generate tags for editors
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 43ab4f000ae3..ef779ada04c6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2577,6 +2577,30 @@ static void write_dump(const char *fname)
free(buf.p);
}

+static void write_symversions_lds(struct module *mod)
+{
+ struct buffer buf = { };
+ struct symbol *sym;
+ char lds_file[PATH_MAX];
+ int ret;
+
+ ret = snprintf(lds_file, sizeof(lds_file), "%s.symver.lds", mod->name);
+ if (ret >= sizeof(lds_file)) {
+ error("%s: too long path was truncated\n", lds_file);
+ return;
+ }
+
+ list_for_each_entry(sym, &mod->exported_symbols, list) {
+ if (!sym->crc_valid)
+ continue;
+
+ buf_printf(&buf, "__crc_%s = 0x%08x;\n", sym->name, sym->crc);
+ }
+
+ write_if_changed(&buf, lds_file);
+ free(buf.p);
+}
+
static void write_namespace_deps_files(const char *fname)
{
struct module *mod;
@@ -2673,6 +2697,9 @@ int main(int argc, char **argv)
char fname[PATH_MAX];
int ret;

+ if (modversions && !mod->from_dump)
+ write_symversions_lds(mod);
+
if (mod->is_vmlinux || mod->from_dump)
continue;

--
2.32.0
\
 
 \ /
  Last update: 2022-04-24 21:14    [W:0.487 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site