From patchwork Sun Nov 4 21:28:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 150123 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1882707ljp; Sun, 4 Nov 2018 13:29:02 -0800 (PST) X-Google-Smtp-Source: AJdET5cW/+dMgDPb74y2vLuQy2PV4LuDUwWco68Pp2eD3l1zmrcOn9yoXBfOVBFMoo0CbDLLT2Jp X-Received: by 2002:aa7:d74f:: with SMTP id a15-v6mr15784389eds.102.1541366942920; Sun, 04 Nov 2018 13:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541366942; cv=none; d=google.com; s=arc-20160816; b=I0/Az9ardUeM1Vy9giw9ox/E6ug49J+XoONZP4yUc2oUTHRVWjyq5sLnc5kT7YYI1e 3t1ZIlgUUl+zkaKunxaymHkfYppoG79VsbA7V1Z09rMkD0UZMiu0r48zbLnkHLHH7szA GrJ+0+C1beUKyJPOfISXI8a3Qn/MT9gphC8CggDTluV64YI2/F66F/dZyuPaQg6q/+9y XqXemc3A2iBk7nqfN6f4PMLbLRfVjmKeJM+Mku/O6jZbHx88i3vds2yAR8MpiBytSbM9 2zmH4eyT8wKiikpFFDBjOIiM+cUM9o8fOyX1WChB4sOAC5XHJZxpL6Mbha56LSLbooEi BrqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from; bh=EgM67n9J/GFp2PccJFHnvROQN3b49pD3IN/wHMd7VqQ=; b=E9guJ0JGxmhPt7XV6aGCiS3qpFEFhjC/3xQ8dXxee6DqAuMKBLLsYBTDl207HWGobL J/Dq3BNUNobtDyAITaKMHGb5mttzaCs8Wx/QpYPHPIOYmpTuB1xqhZNjw7vxTL+d5A7a DfphuAOoPMlg5xRu/hHOR0GzDcX/kWJRqnJPTxRBCYxnp5T14X7fb9sra0OPNAyoNaY7 aMmrygngEnILekLJNzWobdBqngSE/XU1v+wecR/6zpzijiEU1UoVW/0N4yb6S5AKIZS4 H4AejQ8i489zN4EwtrxVoKkIdgTb9wpVOAKsuB9kjKuzSr255cVbyYSKpemPpbFaSH/b WYxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id cx1-v6si2399512ejb.109.2018.11.04.13.29.02; Sun, 04 Nov 2018 13:29:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 74C62C22178; Sun, 4 Nov 2018 21:28:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D8FA4C21F78; Sun, 4 Nov 2018 21:28:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2F47CC21F78; Sun, 4 Nov 2018 21:28:56 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D6A19C21DA1 for ; Sun, 4 Nov 2018 21:28:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 80C85ACBD; Sun, 4 Nov 2018 21:28:55 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Sun, 4 Nov 2018 22:28:55 +0100 Message-Id: <20181104212855.77692-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH] efi_loader: Handle RELA absolute relocations properly X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With RELA absolute relocations, the relocation target contains our link offset which we need to remove from the equation again. We did this properly in the relative relocation path, but not in the absolute one. So let's do this for the absolute one as well. That way, u-boot can have a TEXT_OFFSET of != 0 and still relocate itself properly. This fixes a bug where efi_loader did not work on the RISC-V QEMU port. With this patch, I can successfully run UEFI applications on the RISC-V QEMU port. Reported-by: Auer, Lukas Signed-off-by: Alexander Graf Tested-by: Bin Meng Tested-by: Lukas Auer --- lib/efi_loader/efi_runtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index abcf03c5a4..ca66d33e58 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -380,6 +380,9 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) ulong symidx = rel->info >> SYM_INDEX; extern struct dyn_sym __dyn_sym_start[]; newaddr = __dyn_sym_start[symidx].addr + offset; +#ifdef IS_RELA + newaddr -= CONFIG_SYS_TEXT_BASE; +#endif break; } #endif