From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 23 16:43:05 2013 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2B38BA1E for ; Sat, 23 Feb 2013 16:43:05 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id 2FF4D800 for ; Sat, 23 Feb 2013 16:42:57 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.6/8.14.6) with ESMTP id r1NGgukX082512 for ; Sat, 23 Feb 2013 09:42:57 -0700 (MST) (envelope-from ian@FreeBSD.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id r1NGgXf5056042; Sat, 23 Feb 2013 09:42:33 -0700 (MST) (envelope-from ian@FreeBSD.org) Subject: Re: TFTP single file kernel load From: Ian Lepore To: Wojciech Puchar In-Reply-To: References: Content-Type: text/plain; charset="us-ascii" Date: Sat, 23 Feb 2013 09:42:32 -0700 Message-ID: <1361637752.1185.99.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@FreeBSD.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2013 16:43:05 -0000 On Sat, 2013-02-23 at 16:28 +0100, Wojciech Puchar wrote: > can it be done? > > converting ELF kernel (i don't use kld modules) to format that can be > loaded directly over TFTP - without intermediate stages like loader(8)? > > just to have SINGLE FILE that tftp would load and run. no loader(8) etc. The kernel build process for arm and mips create such a kernel as one of the standard outputs from buildkernel. That doesn't appear to be the case for x86 kernels, but you could use sys/conf/makefile.arm as a guide. Basically what needs doing is to link the kernel with a modified ldscript that doesn't add space for the program headers, and then run the output of that link through "objcopy -S -O binary" to create a kernel.bin file. That file can be directly loaded to the address it was linked for, and a jump to the load address launches the kernel. Whether the kernel runs properly when launched that way is a different question. An arm kernel will run that way because we haven't had the luxury of loader(8) in the arm world until recently. The x86 kernel may expect values in the environment that the loader obtained from the bios. Without a loader you may need to modify the kernel to get that information in some other way early in startup. -- Ian