Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MOVNU-0000nb-8j for mharc-grub-devel@gnu.org; Wed, 08 Jul 2009 07:31:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOVNR-0000jO-UP for grub-devel@gnu.org; Wed, 08 Jul 2009 07:31:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOVNM-0000Wk-Vw for grub-devel@gnu.org; Wed, 08 Jul 2009 07:31:53 -0400 Received: from [199.232.76.173] (port=34194 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOVNM-0000WP-Sl for grub-devel@gnu.org; Wed, 08 Jul 2009 07:31:48 -0400 Received: from mail-px0-f200.google.com ([209.85.216.200]:63588) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOVNM-0007UZ-GG for grub-devel@gnu.org; Wed, 08 Jul 2009 07:31:48 -0400 Received: by pxi38 with SMTP id 38so3879301pxi.14 for ; Wed, 08 Jul 2009 04:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=y1oyFLULOgvnNdH0L9bqFum3GecYtd/JrW8g/FZzZ0k=; b=UFlsCssO/6gEreOFSiLPIgMIb59wyzLXhAqn6vSE/AyHWa6wZLs/kqYSnObo/HNuVl DluPEBTMyc0x+t/gsZY+o9uhsFJcKpwUhkNXpDSBhPoSvukYxPkTLe1QJFYTyA+0njAE jfaPgPM9tS9oHCVYgB7LDIPd7Ldm63vXLrhWA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=i4fsFzmH9EoWH4qdw4HlgEwGifvfpgNmnasWvikwYBEtKje5N66KBschmswg9RfV1A P/R+/v6iOVFGama0Hrw8WK9dx9DD4Safxkrs1TK7NEvzeL/rP+RvFUpDD+ZMjkLBgR0H 1Qd+a0S48xpS3WdYe5rNosBLze+QamIxgFg9A= MIME-Version: 1.0 Received: by 10.115.16.14 with SMTP id t14mr11202638wai.14.1247052706712; Wed, 08 Jul 2009 04:31:46 -0700 (PDT) Date: Wed, 8 Jul 2009 19:31:46 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [RFC] New object format for grub2 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: Wed, 08 Jul 2009 11:31:54 -0000 Hi, Why another format ? Here are some reason: The current object format is ELF. Most unix based os use ELF as native object format, but there are minor difference, and gcc may add extra segment which is of no use for grub. Mingw/cygwin uses PE, and we need to convert it to ELF. Platform like OSX also requires special treatment. All these make the build system complicated, so we might just use an unified format specific to grub. The ELF format is designed to be compatible with many system, it's neither compact nor easy to parse. If we invent a new format, we should make it simple. There are extra data useful to grub, such as module dependence list. It's possible to piggyback it using special segment of ELF, but it's not very clean. We could specify the information explicitly in our own format. Here are my proposed format: struct grub_obj_header { grub_uint32_t magic; grub_uint32_t version; grub_uint32_t mod_attr; grub_uint32_t mod_deps; grub_uint32_t string_table; grub_uint32_t symbol_table; grub_uint32_t init_func; grub_uint32_t fini_func; struct grub_obj_segment segments[0]; } __attribute__((packed)); magic: magic number "GOBJ" version: version number mod_attr: offset to the module attributes mod_deps: offset to the module dependent list string_table: offset to the string table symbol_table: offset to the symbol table init_func: init function offset, init function must be in segment 0 fini_func: fini function offset, fini function must be in segment 0 segments: segment list, ends when segment type is 0 segment structure, the fields should be self explaining struct grub_obj_segment { grub_uint16_t type; grub_uint16_t align; grub_uint32_t offset; grub_uint32_t raw_size; grub_uint32_t mem_size; } __attribute__((packed)); symbol table defines import, export and unnamed symbols, it's the catenation of structure grub_obj_symbol, and ends when segment field is 0xff: #define GRUB_OBJ_SYM_EXPORT 0 #define GRUB_OBJ_SYM_PC32 1 #define GRUB_OBJ_SYM_ABS32 2 #define GRUB_OBJ_SYM_PC64 3 #define GRUB_OBJ_SYM_ABS64 4 struct grub_obj_symbol { grub_uint8_t segment; grub_uint8_t type; grub_uint16_t name; grub_uint32_t offset; } __attribute__((packed)); name is the offset to the string table, if name == 0, it's an unnamed symbol. mod_attr is a series of null-terminated string, ended with an extra 0, it can be used to store information, such as: fs:fat command:ls handler.script:sh we could use it to generate the *.lst files, which is more reliable than sed the source files. mod_deps is a series of null-terminated string, ended with an extra 0. To make it easier to modify, mod_deps should be at the end of the module file. -- Bean