From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KyBhR-0006oz-KB for mharc-grub-devel@gnu.org; Thu, 06 Nov 2008 15:43:29 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KyBhQ-0006np-AK for grub-devel@gnu.org; Thu, 06 Nov 2008 15:43:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KyBhO-0006nD-P1 for grub-devel@gnu.org; Thu, 06 Nov 2008 15:43:27 -0500 Received: from [199.232.76.173] (port=50429 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KyBhO-0006n7-GX for grub-devel@gnu.org; Thu, 06 Nov 2008 15:43:26 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:59459) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KyBhO-000690-0t for grub-devel@gnu.org; Thu, 06 Nov 2008 15:43:26 -0500 Received: from fwd08.aul.t-online.de by mailout07.sul.t-online.de with smtp id 1KyBhM-0006Fk-01; Thu, 06 Nov 2008 21:43:24 +0100 Received: from [10.3.2.2] (ZqUckGZ68hGWjQ-P2AbK2VPj2O0s8S7scStt9yPmiM5i2Ii+kgMV5gND5rLuMSlQCi@[217.235.250.125]) by fwd08.aul.t-online.de with esmtp id 1KyBh7-1MHUO00; Thu, 6 Nov 2008 21:43:09 +0100 Message-ID: <491356DD.4090808@t-online.de> Date: Thu, 06 Nov 2008 21:43:09 +0100 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 MIME-Version: 1.0 To: The development of GRUB 2 References: <20081101123229.GA14438@thorin> <20081101190204.GB4639@thorin> <49109AB8.4010509@nic.fi> <20081104190751.GA25519@thorin> <49109EE7.6050406@nic.fi> <20081104193911.GA26419@thorin> <491143E2.4040705@t-online.de> <20081105094240.GA12201@thorin> <49121300.2050506@t-online.de> <20081106145431.GB24460@thorin> In-Reply-To: <20081106145431.GB24460@thorin> Content-Type: multipart/mixed; boundary="------------030904030806040208050605" X-ID: ZqUckGZ68hGWjQ-P2AbK2VPj2O0s8S7scStt9yPmiM5i2Ii+kgMV5gND5rLuMSlQCi X-TOI-MSGID: 475c01fe-d3d8-4d18-9b31-9af717dd5eda X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: [PATCH] framework for building modules externally X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2008 20:43:28 -0000 This is a multi-part message in MIME format. --------------030904030806040208050605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------030904030806040208050605 Content-Type: text/x-patch; name="grub2-abi-ver.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2-abi-ver.patch" 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 #include +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 #include +char GRUB_ABI_VER_SYM; + #if GRUB_CPU_SIZEOF_VOID_P == 4 typedef Elf32_Word Elf_Word; --------------030904030806040208050605--