From patchwork Wed Jan 21 16:45:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Whitehorn X-Patchwork-Id: 431560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 52F941402A7 for ; Thu, 22 Jan 2015 03:56:38 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 3029D1A0E11 for ; Thu, 22 Jan 2015 03:56:38 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org X-Greylist: delayed 656 seconds by postgrey-1.35 at bilbo; Thu, 22 Jan 2015 03:56:31 AEDT Received: from d.mail.sonic.net (d.mail.sonic.net [64.142.111.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D3B1B1A0E03 for ; Thu, 22 Jan 2015 03:56:31 +1100 (AEDT) Received: from comporellon.tachypleus.net (polaris.tachypleus.net [75.101.50.44]) (authenticated bits=0) by d.mail.sonic.net (8.14.9/8.14.9) with ESMTP id t0LGjPnx027983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Jan 2015 08:45:26 -0800 Message-ID: <54BFD7A5.5080603@freebsd.org> Date: Wed, 21 Jan 2015 08:45:25 -0800 From: Nathan Whitehorn User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: skiboot list X-Sonic-CAuth: UmFuZG9tSVZzvBCdGM74/v640XZL8/EVICM8yOL0LH84a3ddoPmLc4/yv+vyTbqYtYa+/RAkuDqSZZNcz0HiQn0XwOAFgtxYavxYlA6/DI4= X-Sonic-ID: C;jOYU5oyh5BGNV5Cx7jkJAQ== M;ajxU5oyh5BGNV5Cx7jkJAQ== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd Subject: [Skiboot] [PATCH] Load ELF64 binaries correctly X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The attached patch fixes the big-endian ELF64 loader in skiboot to handle the fact that the ELF entry point is specified to point to a function descriptor describing the entry point rather than the entry point itself. (I haven't set it up to load the TOC base pointer though) This is required to load the FreeBSD kernel as a skiboot payload. The patch does not touch the little-endian loader since I'm not sure if the ELFv2 spec still has function descriptors or not. -Nathan diff --git a/core/init.c b/core/init.c index 2c7e30c..6b794ec 100644 --- a/core/init.c +++ b/core/init.c @@ -143,8 +143,10 @@ static bool try_load_elf64(struct elf_hdr *header) (ph->p_vaddr + ph->p_memsz) < kh->e_entry) continue; - /* Get our entry */ - kernel_entry = kh->e_entry - ph->p_vaddr + ph->p_offset; + /* Get our entry: note the function descriptor dereference */ + kernel_entry = *(uint64_t *)(kh->e_entry - ph->p_vaddr + + ph->p_offset + load_base); + kernel_entry = kernel_entry - ph->p_vaddr + ph->p_offset; break; }