From: Christian Franke <Christian.Franke@t-online.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] framework for building modules externally
Date: Thu, 06 Nov 2008 21:43:09 +0100 [thread overview]
Message-ID: <491356DD.4090808@t-online.de> (raw)
In-Reply-To: <20081106145431.GB24460@thorin>
[-- Attachment #1: Type: text/plain, Size: 637 bytes --]
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
[-- Attachment #2: grub2-abi-ver.patch --]
[-- Type: text/x-patch, Size: 1120 bytes --]
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;
next prev parent reply other threads:[~2008-11-06 20:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-01 12:32 [PATCH] framework for building modules externally Robert Millan
2008-11-01 19:02 ` Robert Millan
2008-11-04 18:55 ` Vesa Jääskeläinen
2008-11-04 19:07 ` Robert Millan
2008-11-04 19:13 ` Vesa Jääskeläinen
2008-11-04 19:39 ` Robert Millan
2008-11-05 6:57 ` Christian Franke
2008-11-05 9:42 ` Robert Millan
2008-11-05 21:41 ` Christian Franke
2008-11-06 14:52 ` __FILE__ (Re: [PATCH] framework for building modules externally) Robert Millan
2008-11-06 21:10 ` Christian Franke
2008-11-07 19:02 ` Robert Millan
2008-11-10 20:39 ` Christian Franke
2008-11-06 14:54 ` [PATCH] framework for building modules externally Robert Millan
2008-11-06 20:43 ` Christian Franke [this message]
2008-11-07 19:05 ` Robert Millan
2008-11-08 11:33 ` Robert Millan
2008-11-10 20:44 ` Christian Franke
2009-04-10 23:19 ` phcoder
2009-04-13 13:55 ` Robert Millan
2008-11-05 9:51 ` Robert Millan
2008-11-08 11:29 ` Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=491356DD.4090808@t-online.de \
--to=christian.franke@t-online.de \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.