grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] framework for building modules externally


From: Christian Franke
Subject: Re: [PATCH] framework for building modules externally
Date: Thu, 06 Nov 2008 21:43:09 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11

Robert Millan wrote:
On Wed, Nov 05, 2008 at 10:41:20PM +0100, Christian Franke wrote:
Then, a module author has the option to check the ABI version by importing this symbol
(possibly by simply adding '-u grub_abi_VERSION' to ld command)

How would the whole picture look like?  Sounds like it'd mean less complexity
in external modules at the expense of more complexity in the build system.


Here a first proof-of-concept patch, uses hello.c as the external module.

If kernel is compiled with other GRUB_ABI_VER_SYM, insmod fails with:
"error: the symbol 'grub_abi_ver_1_96' not found"

Christian

diff --git a/hello/hello.c b/hello/hello.c
index 70cbf60..4eb2483 100644
--- a/hello/hello.c
+++ b/hello/hello.c
@@ -25,6 +25,8 @@
 #include <grub/dl.h>
 #include <grub/normal.h>
 
+GRUB_ABI_VER_CHECK;
+
 static grub_err_t
 grub_cmd_hello (struct grub_arg_list *state __attribute__ ((unused)),
                int argc __attribute__ ((unused)),
diff --git a/include/grub/dl.h b/include/grub/dl.h
index bdde089..3efc05e 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -93,4 +93,11 @@ void *EXPORT_FUNC(grub_dl_resolve_symbol) (const char *name);
 grub_err_t grub_arch_dl_check_header (void *ehdr);
 grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
 
+#define GRUB_ABI_VER_SYM  grub_abi_ver_1_96
+
+extern char EXPORT_VAR(GRUB_ABI_VER_SYM);
+
+#define GRUB_ABI_VER_CHECK \
+char * grub_abi_ver_check = &GRUB_ABI_VER_SYM
+
 #endif /* ! GRUB_DL_H */
diff --git a/kern/dl.c b/kern/dl.c
index b483134..32591f4 100644
--- a/kern/dl.c
+++ b/kern/dl.c
@@ -29,6 +29,8 @@
 #include <grub/env.h>
 #include <grub/cache.h>
 
+char GRUB_ABI_VER_SYM;
+
 #if GRUB_CPU_SIZEOF_VOID_P == 4
 
 typedef Elf32_Word Elf_Word;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]