From patchwork Mon Oct 14 12:56:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1176348 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="pgUJgMQ7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46sJZb4Plxz9sPT for ; Tue, 15 Oct 2019 00:00:39 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 122D1C21E56; Mon, 14 Oct 2019 12:59:11 +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=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID 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 CD883C21EFD; Mon, 14 Oct 2019 12:59:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 57504C21F06; Mon, 14 Oct 2019 12:56:43 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id 37480C21EA8 for ; Mon, 14 Oct 2019 12:56:42 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h4so19642503wrv.7 for ; Mon, 14 Oct 2019 05:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=76yJ1RJUsM9ZonubT71pXKvpQCku81mbIaig6UWjTs8=; b=pgUJgMQ7ut9mhiIdfsMjv1oUd8zzUhti7fiBz6yiGolfF8rfDtrtS5lModxl1UmWrL X+vQuwGNVcFf6OCQhTAq+lwygkyn56XhUxJG07Rnj+GftWWnH6vpuxQopvZJBKgRsLYR OEcVt4f7cwUVg/qkTb7PDY+Zg/i0CQXAdvQyIXmkdm6io5uYYfLnShNeKhcV5IA+spL6 y7sW2Oq/yeYzTUsM0q4zbypXQzPL5ZoA8H6WGnQ9G5tQaXvAhhwoQO2j+y2OeQEIne7n ba+/0nKP+m+dkjV1YwI07Uev2igB5mt8/G6E9LPCpNouzgV7MiW70XO1COmugd0X7VTr 4MHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=76yJ1RJUsM9ZonubT71pXKvpQCku81mbIaig6UWjTs8=; b=hkZ/Lka8/PgE4ZXvSp8LiugZU99TLqYtWBpQaabOKcWg/NeET+puZXJeaeDO7iKDrO usmvgKGuzwcQkwFvUFs501BACheRp6lwHAxzYAw0V3y4HtlsTKKG+eGY81rosEVRXl/t Wlm2yQccf5aCO8KEjieFtvsLWZHVKYd38EuHfQd7Ov3JBWS4VQ7HotfsxbAzJcmerkSr IykEQ90f1jAtVHqsdRGxNUHZk/htmwM986v7SoO/aswDRYEC+z2ovfoC52A3sNP4akxB ZM+4i+qtc5XIYa3vjJbmVBM4ajoZ+1eezTD5K6C68PyTxmXwNcO8snDGSt5FvGO2oW9p qWgw== X-Gm-Message-State: APjAAAU1hVEsxyFsEAmrRHRTkDSzrZvsd3uOsSqxAkwVNoMG76X5WAGk pVcUGmMYPjnhBzitjzsII1LQzit7Gqvu1Q== X-Google-Smtp-Source: APXvYqzD2yVK6jUrivq/zQLNXa72IUlWi+JTIwqquD8DJfwl91l52ta1Nd0iqwfu3DkbWpPA6pYYwQ== X-Received: by 2002:adf:f18a:: with SMTP id h10mr1448017wro.145.1571057801609; Mon, 14 Oct 2019 05:56:41 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id i11sm20558872wrw.57.2019.10.14.05.56.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 05:56:40 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Mon, 14 Oct 2019 14:56:35 +0200 Message-Id: <2538531aba93f7bef01450e0c3640d99ad7c22aa.1571057794.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Joe Hershberger , T Karthik Reddy Subject: [U-Boot] [PATCH 1/3] common: hash: Manually relocate struct hash_algo 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" From: T Karthik Reddy This patch adds manual relocation for struct hash_algo if CONFIG_NEEDS_MANUAL_RELOC is enabled. Signed-off-by: T Karthik Reddy Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Michal Simek --- common/hash.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/common/hash.c b/common/hash.c index d33e329897e1..d0d825e38986 100644 --- a/common/hash.c +++ b/common/hash.c @@ -30,6 +30,12 @@ #include #include +#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC) +DECLARE_GLOBAL_DATA_PTR; +#endif + +static void reloc_update(void); + #if defined(CONFIG_SHA1) && !defined(CONFIG_SHA_PROG_HW_ACCEL) static int hash_init_sha1(struct hash_algo *algo, void **ctxp) { @@ -215,10 +221,31 @@ static struct hash_algo hash_algo[] = { #define multi_hash() 0 #endif +static void reloc_update(void) +{ +#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC) + int i; + static bool done; + + if (!done) { + done = true; + for (i = 0; i < ARRAY_SIZE(hash_algo); i++) { + hash_algo[i].name += gd->reloc_off; + hash_algo[i].hash_func_ws += gd->reloc_off; + hash_algo[i].hash_init += gd->reloc_off; + hash_algo[i].hash_update += gd->reloc_off; + hash_algo[i].hash_finish += gd->reloc_off; + } + } +#endif +} + int hash_lookup_algo(const char *algo_name, struct hash_algo **algop) { int i; + reloc_update(); + for (i = 0; i < ARRAY_SIZE(hash_algo); i++) { if (!strcmp(algo_name, hash_algo[i].name)) { *algop = &hash_algo[i]; @@ -235,6 +262,8 @@ int hash_progressive_lookup_algo(const char *algo_name, { int i; + reloc_update(); + for (i = 0; i < ARRAY_SIZE(hash_algo); i++) { if (!strcmp(algo_name, hash_algo[i].name)) { if (hash_algo[i].hash_init) {