From patchwork Sun Dec 15 23:39:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Niethe X-Patchwork-Id: 1210036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bgr05vldz9sPT for ; Mon, 16 Dec 2019 10:40:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SVpz1gsk"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47bgr04jVbzDqX0 for ; Mon, 16 Dec 2019 10:40:16 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=jniethe5@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SVpz1gsk"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47bgqp4Z1vzDqWj for ; Mon, 16 Dec 2019 10:40:05 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id b137so2605046pga.6 for ; Sun, 15 Dec 2019 15:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2wURa8D7Fa9YYRbu5pL369jMChMFFf8uP6g073yIYRs=; b=SVpz1gskkIjsx8vDisDMOdmLTqTqcap/gKGmOfVZjfqMjdaOddBcRrr38mbJ0vNwH5 yWA7Yu6uXNGfD9ew4rh/fFo+pdy1C5JY0aN3+Efs64mkI1MrWCmzR7lpVednTCyIrNXA gN9e+aR5xmBTJkbIyWGIKhexwxL1IAPtRNx8vgENm6x5A8gcIrVVpQhvJ770ZanmSOXq C0vvmwVp+lc0hP35ehthxSeH+C1OR/tfmsIJ939dLQnZyZZ30g3yBq7fesxgsYvdaGl/ wVBffijOGckiB+nx0b5nETaI4GOBWKttrKaym52QS3/+yODiO/yIaUPDMn/SK2izEE/V OQUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2wURa8D7Fa9YYRbu5pL369jMChMFFf8uP6g073yIYRs=; b=TQ3ZZdUuEThpGkGesmK/toBHhizVW4ND1z5BTEKYTaJVKxMuZO4E3EhdEB0vVW0VIx LsUwpVBS7UQmngDezakZppSlb5ds6K2VXs+2JQDN+FEVMVjNPVDmlb+cXGkDb2iqSnv+ +cSzg5hUXOf2/AAWm0xWjc2OanCApitjOiuTyQRoRPoS4Kr4/PnienXvzB6yfPMZIF7K NTmyk1j/CeH9WQXc65Mh8R/n2Eh75iMh72K2NEBk6AmlUPAsNNoAwTwJmQX/Q1vN09El BeZvIdxcb6v7BaWjtwajT42qkAX3ot/GJ5x9zH8utvjE9Clc5q64usTS7QS4rHZMBvaF zNQQ== X-Gm-Message-State: APjAAAU/CJkrFS4h+ueZNXUn1eW3IMTe0QA6CaL81UUSmLAdQ6Sjxa0s 4JEWhS/+zXAihCIx0ne3YVJk5ctn X-Google-Smtp-Source: APXvYqz8aojajBPyrIFzA8xCmRffsf5ZO9rNMBNjlDq1HiCIqUMlmMO6RRbgt3rz228Qsz41X6Zuuw== X-Received: by 2002:a65:68d4:: with SMTP id k20mr14895844pgt.142.1576453201945; Sun, 15 Dec 2019 15:40:01 -0800 (PST) Received: from tee480.au.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 11sm18033340pfj.130.2019.12.15.15.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2019 15:40:01 -0800 (PST) From: Jordan Niethe To: skiboot@lists.ozlabs.org Date: Mon, 16 Dec 2019 10:39:27 +1100 Message-Id: <20191215233927.335-1-jniethe5@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Skiboot] [PATCH] core/init: Fix loading BE elfs with no sections X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" A big-endian elf will either have its entry pointing to a function description in the data section, or directly pointing to the code. However currently an elf which has no sections will be treated as its entry pointing to a function descriptor. For elfs with no sections, (e.g., created by plan9 linkers) this assumption is incorrect, causing skiboot to enter at the wrong location. If an elf has no sections, treat the entry as pointing directly to code. Signed-off-by: Jordan Niethe --- core/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/init.c b/core/init.c index a7083456e5cb..0134e0e4ac66 100644 --- a/core/init.c +++ b/core/init.c @@ -196,7 +196,7 @@ static bool try_load_elf64(struct elf_hdr *header) break; } - if (i == kh->e_shnum || !(sh->sh_flags & ELF_SFLAGS_X)) { + if (i && (i == kh->e_shnum || !(sh->sh_flags & ELF_SFLAGS_X))) { kernel_entry = *(uint64_t *)(kernel_entry + load_base); kernel_entry = kernel_entry - ph->p_vaddr + ph->p_offset; }