From patchwork Tue Jun 7 08:10:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639841 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=Vz8OhkU0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNP649HVz9sFs for ; Tue, 7 Jun 2022 18:11:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E3ADB842E0; Tue, 7 Jun 2022 10:10:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="Vz8OhkU0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1CF61842C2; Tue, 7 Jun 2022 10:10:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 01E8E842C2 for ; Tue, 7 Jun 2022 10:10:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52d.google.com with SMTP id w27so21867240edl.7 for ; Tue, 07 Jun 2022 01:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JZUwFnmidULUk7vTHm2uGLluDa5BlIhW14O1m7AbnHc=; b=Vz8OhkU0d/JGmyLnbH3dkwr1vCLTdMdk3d0X7mW2HXpmZEhU1A+Mpe1v2OVAOzGxQJ mEIqzK/fqxTjU0Bpl8ia4RVSSsj9u2QvSor4qEOLV+EdoZaqRVHmFWg+0MAi/qxCO8Da gztJ1vq9OKLnsm4fjrmSTj4f0ej91rAsQCMYUyK+GfJY4V0Kn7ctv0qqmtZ0M43wSpHo u5uNYMwXcEB18tUToqMAROZnLsRf/IEznUTwsmLe5m+tp8zKsxGtlP7P1aN0101U0FDu oDx0PVyJfiZ5TsNyIyyWvXBtNFAlSsCm5sdS8m+h+GQraX/LPe2QIp0gOWjovWJtMYiN KhNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JZUwFnmidULUk7vTHm2uGLluDa5BlIhW14O1m7AbnHc=; b=rSzoJSOIoxXVWthcNU97I4vgFuG4LEXzXhaDv/gofVdaxKkQgHWTq+xOaAEmrfWKbP RIcfzktbnng7riiZZsd74IT0Z+ADVM9a9dCc71Q/6DWCavb0AOrW1etTq3rCxpFmDvlT Jh+vmBTK/CstSqpGbxWYDgyPxCoTD88aBVUrNCQcGOqElpKvksEJVLGrTeeU6+STXfje uXO+ZpkIkKLBMT8zzticB9/UIUdo2jdUtZTs6vlCM5PmIBDsuw1pQhmf0mxLSxI86nJl In1pGTuh0qqmEFwzGYbU2Om7S1FfTRI5ctcfrLl1AQbW69rzOMfObB0MC6tmm+Odt1p1 Ii3A== X-Gm-Message-State: AOAM531Tq+1kUqmiBAz7GJ0bLU7VXdGWC8F4soFZgn/LmedipIZhKGPF /Ky94fvqWjuf22twHDhp0/bgY2+4zzGYCA== X-Google-Smtp-Source: ABdhPJwUQzlF/2V95zTWzVjBt4/ztPIXbFd2QWnF69JOi2z0Fz023RAl8sdFQsFcrmKhuvN0ncJmxA== X-Received: by 2002:a05:6402:528a:b0:42d:e116:fab8 with SMTP id en10-20020a056402528a00b0042de116fab8mr31140502edb.134.1654589447313; Tue, 07 Jun 2022 01:10:47 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id bs13-20020a056402304d00b0042bd6f745fasm9807995edb.92.2022.06.07.01.10.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:46 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 01/23] tools: relocate-rela: Open binary u-boot file later Date: Tue, 7 Jun 2022 10:10:18 +0200 Message-Id: <493b4309a6124bc3c36954153131d95cde75431b.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean There is no value to open u-boot binary file so early. Better to check all values first and then open binary file. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index f0bc548617a4..883987111869 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -73,13 +73,6 @@ int main(int argc, char **argv) return 1; } - f = fopen(argv[1], "r+b"); - if (!f) { - fprintf(stderr, "%s: Cannot open %s: %s\n", - argv[0], argv[1], strerror(errno)); - return 2; - } - if (!read_num(argv[2], &text_base) || !read_num(argv[3], &rela_start) || !read_num(argv[4], &rela_end)) { @@ -95,6 +88,13 @@ int main(int argc, char **argv) rela_start -= text_base; rela_end -= text_base; + f = fopen(argv[1], "r+b"); + if (!f) { + fprintf(stderr, "%s: Cannot open %s: %s\n", + argv[0], argv[1], strerror(errno)); + return 2; + } + fseek(f, 0, SEEK_END); file_size = ftell(f); rewind(f); From patchwork Tue Jun 7 08:10:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639842 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=iJ3/Dxqe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNPG33lRz9sFs for ; Tue, 7 Jun 2022 18:12:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 94B4C842C4; Tue, 7 Jun 2022 10:11:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="iJ3/Dxqe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9235E842DC; Tue, 7 Jun 2022 10:10:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CDCC684288 for ; Tue, 7 Jun 2022 10:10:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52d.google.com with SMTP id er5so21885515edb.12 for ; Tue, 07 Jun 2022 01:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a54sJWK98poOUa7QsK2LhkJ0BEpvknanx5UWf5Yz3Ko=; b=iJ3/DxqeKDdSiHQsbpGKxtI+1Lr86bem0JJNCcGxBM1BpaWac7Vwu3lr2J/H/FLIAs MOdylEvDkTxOchhOxjg59+TvcfLgx4WsA5QCDuE0VIHPFqd+PZM5rn7wVroipufvQQ/9 0/ROIjGOjoCJd+OVD7JcOQA/Dim1d9rqk41zelnxci++iA1veAuoPHLQsfqDhE7pMUS1 PH+W6wKisG4suk3PYVCvta2wxKsX9VSt3Exa5N6CQWkINZwd6DvgvjxSYyF5tCbEOhju Ym0t9+h1RCxdg7drQ9FqE4GYJ+y+H413RV2bplUgWEvqe1HgjbXn8cCh6MBEvFBfyR4M rviw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a54sJWK98poOUa7QsK2LhkJ0BEpvknanx5UWf5Yz3Ko=; b=fYXtk9X8MOCpPF4nOf4+PDnGepDu7O0ceHtiwlnwxMV/Yvx5kHKRO5pbbjrUZUytZa lFhQJt0hbmEwAqjNjlf+bFHKugJG61FCzZpB287zzIqPG4eAJt2GoR/YsKc6+kE9rKkN OtopqypSlKJpzO77nJkKpyrK5vKs30+MEKHX+4dmKwAAMZrARFbmc9SirA0oTtJzNWK+ 6aTbQ5ky6NI5qowVPeW2+AhNP1c5AooAmUiatSM2hbcilb6sq+QLD57f0miCobCt2Dyn qhz7r9/HQJhCYOAjXZoJdqVHH4a24iVFMBZfXnz24ziFPqI+qjVQGHJln++jkeQEg/FX i8LQ== X-Gm-Message-State: AOAM5303w0KYOTK4dL73oHK1Kd8ULTtKS/gRjd2gPVANZPzj52IjsNPa 4vgNBN/aMNk13eBYBL1Q8zQbsYDnGlpWAA== X-Google-Smtp-Source: ABdhPJye0YYSPEIia6elG16GzT/E1HpPJDz5Hf0lGiCJ6hgNa7EIybTyuedKN0ZGFeB0oYlo4aPyfw== X-Received: by 2002:a50:fc10:0:b0:42d:cbd2:4477 with SMTP id i16-20020a50fc10000000b0042dcbd24477mr31508690edr.363.1654589449969; Tue, 07 Jun 2022 01:10:49 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id s23-20020a170906501700b006fefd1d5c2bsm7353830ejj.148.2022.06.07.01.10.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:48 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Heinrich Schuchardt , Simon Glass Subject: [PATCH v2 02/23] Makefile: Fix description for relocate-rela parameters Date: Tue, 7 Jun 2022 10:10:19 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Numbers in comment are shifter which is visible from command which calls them. Also relocate-rela usage is describing them. "Usage: %s " Signed-off-by: Michal Simek --- (no changes since v1) Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2fa3a3b488e6..2270ec5c7938 100644 --- a/Makefile +++ b/Makefile @@ -922,7 +922,7 @@ endif # the raw binary, but certain simulators only accept an ELF file (but don't # do the relocation). ifneq ($(CONFIG_STATIC_RELA),) -# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base +# $(2) is u-boot ELF, $(3) is u-boot bin, $(4) is text base quiet_cmd_static_rela = RELOC $@ cmd_static_rela = \ start=$$($(NM) $(2) | grep __rel_dyn_start | cut -f 1 -d ' '); \ From patchwork Tue Jun 7 08:10:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639843 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=l5jBcDW8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNPW2XyQz9sFs for ; Tue, 7 Jun 2022 18:12:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC42D84337; Tue, 7 Jun 2022 10:11:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="l5jBcDW8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0568842C4; Tue, 7 Jun 2022 10:10:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 22F0F842C4 for ; Tue, 7 Jun 2022 10:10:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x62a.google.com with SMTP id q1so33579225ejz.9 for ; Tue, 07 Jun 2022 01:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oTkshP69xYswgmg+YnTRs6B8wROWaYzZPGAAiK/27UE=; b=l5jBcDW8mJaSxSQPwCAP4Rd/nR18q7RoAYVJdq26NWHlg+JPgQMctnfcUKN/ipu+9I t5PNuEnJNpHIX24/TmZm3B4CI2p7TLz7pTzJUZkBOZKeQF5w1OEvojMFY6DJu15+exsa ES1xgiiqZhioAQCKJ/Rd8CeTyK3JzgPfLB1QQ4fu7JtdRpXtMzIWQQyrH0ATdo+NZ//4 ti1i0izGtn/XjZttajorQI0e9JIGLzNQNQSNw1I17TmKuBXSKJTTUVObbtY86XEv75n9 vzA7An/RDzR2ppxsHz741FpNteuKfqBDloNW/FMmC/a08cdzXOwW2REzbewY4gQYYMCf ogjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oTkshP69xYswgmg+YnTRs6B8wROWaYzZPGAAiK/27UE=; b=dz3cDvzjlsJi9PmgLpFhzbD+FVSudt3HeY8U/FklLPQpUuRTOnfnyKaAsKGWFhgEY7 txavPMZ7QnNSrrKbRVzWN5ZmLyYLyTYAyfT+uPiHChPbFankHPx1Qjk1GM2N7P0ABHAN VAPmZRUXASK1I99adgQwoQrwR/DwZOzm6m3AtRoycg0fcIYVhA+1FqwTgeJS41vvkcW8 4QxRLwqCOghG70xuKKkIx64702XTKCInwiwNBJ+cbVpF2geim7FsEDRNW8x8STJr5SFO j4ChUEMlea5oHN1vmJXkqzFkvOw/mFfIR8lvaAoTKm6A4qf8+VountMG3FtCGeHJoFb1 otxQ== X-Gm-Message-State: AOAM531MXnNBm0pjsMdxOCe5MACopRmbA6SK3YBm47oFr/wcbRHRocf0 /AHeaUR6AGtwc0ji2yrpy2kLsPpDErXjJw== X-Google-Smtp-Source: ABdhPJwEYbxwcaaTAG7ZlsYzOMZv8zX9Kedjd+ResLY8MFzyVhk+q1jn5Nb/V9qerpPIriinf3C1Pg== X-Received: by 2002:a17:907:972a:b0:6f4:f456:50a7 with SMTP id jg42-20020a170907972a00b006f4f45650a7mr24922351ejc.431.1654589452076; Tue, 07 Jun 2022 01:10:52 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id n8-20020aa7d048000000b0042dcdfb003esm9870426edo.53.2022.06.07.01.10.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:51 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 03/23] tools: relocate-rela: Use global variables Date: Tue, 7 Jun 2022 10:10:20 +0200 Message-Id: <2d65fc56c3785f2e1ad4d2d21f84856ca5c7c268.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Declare rela_start/end and text_base as global variables. It will help with using these variables for ELF decoding. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 883987111869..67a138aa67d7 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -20,6 +20,8 @@ #define R_AARCH64_RELATIVE 1027 #endif +static uint64_t rela_start, rela_end, text_base; + static const bool debug_en; static void debug(const char *fmt, ...) @@ -63,7 +65,7 @@ int main(int argc, char **argv) { FILE *f; int i, num; - uint64_t rela_start, rela_end, text_base, file_size; + uint64_t file_size; if (argc != 5) { fprintf(stderr, "Statically apply ELF rela relocations\n"); From patchwork Tue Jun 7 08:10:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639844 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=EQ1vThme; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNPl1z3yz9sFs for ; Tue, 7 Jun 2022 18:12:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2144E84358; Tue, 7 Jun 2022 10:11:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="EQ1vThme"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 321D684300; Tue, 7 Jun 2022 10:11:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 951AC84293 for ; Tue, 7 Jun 2022 10:10:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x536.google.com with SMTP id v19so21893116edd.4 for ; Tue, 07 Jun 2022 01:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oDgQd9ZV0rMNbmBSn/9aM+oL+qXnkhDLW/DMEUqwnWE=; b=EQ1vThmeE9rwapSJGKW7l4Yr5bDpY2SW2g90IFNZ8opW7AGcaYJYpqVrzxNck6+Mg+ EL+qvPdXGPT3tif7EvrVEjFFfkIunfq2LsFGeTXNg1QVg5OymUUABewO5GMCVL9s/JGI GqupRMuDhGFGroEpGvwrwMjHc1i5kb+6mPvxSLpl8C/rjFtPTl1meOkT/cnEML2/u+NG VgHPAUl4HX7SX1yheGL3o41wBxZUvLnwDjGcQZFpjw8JXVePc+tpS3OFFu0/Cqptl+DU XRp+ly20zCAiThW99MX2XSwIit/H7FLAMQdK2Ks8aUh9rQcPQdswykDNuoZUckOkB4fm jZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oDgQd9ZV0rMNbmBSn/9aM+oL+qXnkhDLW/DMEUqwnWE=; b=qH+1KCuxDrm/yHeQtvxkYN4YEhA1JmaQT0YOX7M6dc8ldmH+fvA9THgpw4XHE5ObSH DAvDeFtLJ75OMZ2s7nrAPUze6NFcwr2VRovVIHqh0u16LfxLgNXK6tj5G/QOq0U3WRSm qdDflNucBy5RGsmuDR+AUqWv48YTiAJLTUSrOxpAU9estGawJVJ3YNgomFHCEu8B/96b 6F6D50Hb1c8ThzuZSbxhPafrWBoxZ45EoI/rS0cNeBAZ7DcSFZRfDrhjAIjmKm1H5BbT eWp3kzLzPhVML0WX0CzMEaH6TVbgr38lXHgE2yRu5gei7VsSWkkHQKLYViO6Odkq7QIg fX9g== X-Gm-Message-State: AOAM533+GP/yfauzK3i9uO21Dteoi/gRUOtQfcq0W5pWYegB6M7obHWF /o+SVQxT0NWv52Wp8DqY79S1O1GNPlyVow== X-Google-Smtp-Source: ABdhPJz4TAG8tBK7gQyNMDzqbShGvC2CZV3XgLu/6A987LXXb66BfLH1/eQ9AE1Gtk4K7lkmbWuC4g== X-Received: by 2002:a05:6402:149:b0:431:7dde:9b59 with SMTP id s9-20020a056402014900b004317dde9b59mr4310470edu.339.1654589453711; Tue, 07 Jun 2022 01:10:53 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id k24-20020aa7c398000000b0042dcac2afc6sm9763316edq.72.2022.06.07.01.10.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:53 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva , Heinrich Schuchardt , Simon Glass Subject: [PATCH v2 04/23] tools: relocate-rela: Read rela start/end directly from ELF Date: Tue, 7 Jun 2022 10:10:21 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean There is no need to pass section information via parameters. Let's read text base and rela start/end directly from elf. It will help with reading other information from ELF for others architecture. Input to relocate-rela is u-boot binary and u-boot ELF. Signed-off-by: Michal Simek --- (no changes since v1) Makefile | 4 +- tools/relocate-rela.c | 181 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 168 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 2270ec5c7938..55c55dbb7e2b 100644 --- a/Makefile +++ b/Makefile @@ -925,9 +925,7 @@ ifneq ($(CONFIG_STATIC_RELA),) # $(2) is u-boot ELF, $(3) is u-boot bin, $(4) is text base quiet_cmd_static_rela = RELOC $@ cmd_static_rela = \ - start=$$($(NM) $(2) | grep __rel_dyn_start | cut -f 1 -d ' '); \ - end=$$($(NM) $(2) | grep __rel_dyn_end | cut -f 1 -d ' '); \ - tools/relocate-rela $(3) $(4) $$start $$end + tools/relocate-rela $(3) $(2) else quiet_cmd_static_rela = cmd_static_rela = diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 67a138aa67d7..36065edb3f01 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -20,6 +20,8 @@ #define R_AARCH64_RELATIVE 1027 #endif +static int ei_class; + static uint64_t rela_start, rela_end, text_base; static const bool debug_en; @@ -54,32 +56,183 @@ static bool supported_rela(Elf64_Rela *rela) } } -static bool read_num(const char *str, uint64_t *num) +static int decode_elf64(FILE *felf, char **argv) +{ + size_t size; + Elf64_Ehdr header; + uint64_t section_header_base, section_header_size, sh_offset, sh_size; + Elf64_Shdr *sh_table; /* Elf symbol table */ + int ret, i, machine; + char *sh_str; + + debug("64bit version\n"); + + /* Make sure we are at start */ + rewind(felf); + + size = fread(&header, 1, sizeof(header), felf); + if (size != sizeof(header)) { + fclose(felf); + return 25; + } + + machine = header.e_machine; + debug("Machine\t%d\n", machine); + + text_base = header.e_entry; + section_header_base = header.e_shoff; + section_header_size = header.e_shentsize * header.e_shnum; + + sh_table = malloc(section_header_size); + if (!sh_table) { + fprintf(stderr, "%s: Cannot allocate space for section header\n", + argv[0]); + fclose(felf); + return 26; + } + + ret = fseek(felf, section_header_base, SEEK_SET); + if (ret) { + fprintf(stderr, "%s: Can't set pointer to section header: %x/%lx\n", + argv[0], ret, section_header_base); + free(sh_table); + fclose(felf); + return 26; + } + + size = fread(sh_table, 1, section_header_size, felf); + if (size != section_header_size) { + fprintf(stderr, "%s: Can't read section header: %lx/%lx\n", + argv[0], size, section_header_size); + free(sh_table); + fclose(felf); + return 27; + } + + sh_size = sh_table[header.e_shstrndx].sh_size; + debug("e_shstrndx\t0x%08x\n", header.e_shstrndx); + debug("sh_size\t\t0x%08lx\n", sh_size); + + sh_str = malloc(sh_size); + if (!sh_str) { + fprintf(stderr, "malloc failed\n"); + free(sh_table); + fclose(felf); + return 28; + } + + /* + * Specifies the byte offset from the beginning of the file + * to the first byte in the section. + */ + sh_offset = sh_table[header.e_shstrndx].sh_offset; + + debug("sh_offset\t0x%08x\n", header.e_shnum); + + ret = fseek(felf, sh_offset, SEEK_SET); + if (ret) { + fprintf(stderr, "Setting up sh_offset failed\n"); + free(sh_str); + free(sh_table); + fclose(felf); + return 29; + } + + size = fread(sh_str, 1, sh_size, felf); + if (size != sh_size) { + fprintf(stderr, "%s: Can't read section: %lx/%lx\n", + argv[0], size, sh_size); + free(sh_str); + free(sh_table); + fclose(felf); + return 30; + } + + for (i = 0; i < header.e_shnum; i++) { + /* fprintf(stderr, "%s\n", sh_str + sh_table[i].sh_name); Debug only */ + if (!strcmp(".rela.dyn", (sh_str + sh_table[i].sh_name))) { + debug("Found section\t\".rela_dyn\"\n"); + debug(" at addr\t0x%08x\n", + (unsigned int)sh_table[i].sh_addr); + debug(" at offset\t0x%08x\n", + (unsigned int)sh_table[i].sh_offset); + debug(" of size\t0x%08x\n", + (unsigned int)sh_table[i].sh_size); + rela_start = sh_table[i].sh_addr; + rela_end = rela_start + sh_table[i].sh_size; + break; + } + } + + /* Clean up */ + free(sh_str); + free(sh_table); + fclose(felf); + + debug("text_base\t0x%08lx\n", text_base); + debug("rela_start\t0x%08lx\n", rela_start); + debug("rela_end\t0x%08lx\n", rela_end); + + if (!rela_start) + return 1; + + return 0; +} + +static int decode_elf(char **argv) { - char *endptr; - *num = strtoull(str, &endptr, 16); - return str[0] && !endptr[0]; + FILE *felf; + size_t size; + unsigned char e_ident[EI_NIDENT]; + + felf = fopen(argv[2], "r+b"); + if (!felf) { + fprintf(stderr, "%s: Cannot open %s: %s\n", + argv[0], argv[5], strerror(errno)); + return 2; + } + + size = fread(e_ident, 1, EI_NIDENT, felf); + if (size != EI_NIDENT) { + fclose(felf); + return 25; + } + + /* Check if this is really ELF file */ + if (e_ident[0] != 0x7f && + e_ident[1] != 'E' && + e_ident[2] != 'L' && + e_ident[3] != 'F') { + fclose(felf); + return 1; + } + + ei_class = e_ident[4]; + debug("EI_CLASS(1=32bit, 2=64bit) %d\n", ei_class); + + if (ei_class == 2) + return decode_elf64(felf, argv); + + return 1; } int main(int argc, char **argv) { FILE *f; - int i, num; + int i, num, ret; uint64_t file_size; - if (argc != 5) { + if (argc != 3) { fprintf(stderr, "Statically apply ELF rela relocations\n"); - fprintf(stderr, "Usage: %s " \ - " \n", argv[0]); - fprintf(stderr, "All numbers in hex.\n"); + fprintf(stderr, "Usage: %s \n", + argv[0]); return 1; } - if (!read_num(argv[2], &text_base) || - !read_num(argv[3], &rela_start) || - !read_num(argv[4], &rela_end)) { - fprintf(stderr, "%s: bad number\n", argv[0]); - return 3; + ret = decode_elf(argv); + if (ret) { + fprintf(stderr, "ELF decoding failed\n"); + return ret; } if (rela_start > rela_end || rela_start < text_base) { From patchwork Tue Jun 7 08:10:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639845 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ZKZii/jY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNPz4TT2z9sFs for ; Tue, 7 Jun 2022 18:12:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDC878435C; Tue, 7 Jun 2022 10:12:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="ZKZii/jY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C49AB84293; Tue, 7 Jun 2022 10:11:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7D7BC842E6 for ; Tue, 7 Jun 2022 10:10:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52d.google.com with SMTP id o10so21893616edi.1 for ; Tue, 07 Jun 2022 01:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=goSGkyS3+F8EcwiEi+zc0jDtiGBPZicN9F4fEKzH1h8=; b=ZKZii/jYLaKWl7UXQHY0AsR622UvKTfNyrKinU8ZBMVJKgTfBD/XaLbRBEBvoQiVwc UGbP7+lPdieCFtOW+hLHLyCEE/we0ZCPVBOjkHqWmGoTZp2nh1Xs/NZ868uTOaI42/Xx M2luCqp25UO1s2LAj9+fvUkrn8K47qkA1lN7HqahlR+zCVylj/RgFZRQYm0HhZZkUSk2 fzkoyg9wVMHtDUD1KHaVQvKpFJTCZHA/c+KOMyTgsUsHtgCDyqt9E0DF6LpLRILfS37O KqyxlqGgno1jwugzjPuP/pPc2fnI4fHLRgZIDa2ih5G/iJtWINtQ9jwX3UM0Zz/LlUK0 Jy2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=goSGkyS3+F8EcwiEi+zc0jDtiGBPZicN9F4fEKzH1h8=; b=LSpmaHEp/WbGG2j081ZDqN9aMIvvyi8eNNwTg6sVzVXqaC6unqraR/T6TsTsDrMro4 VeGDvxBaNZfPmR+OqVO9JjroKoQwQngTdMuwNknw6HqjDNuuKs4J1fxSFP6poV1EOh4T f930gFalout+6R0LoZooq16j5WOUiSBXJ+CjtndjisJNyiqX2DjxW1SsKxa4FacwSDr+ N7C3LcSDgUN/owPc8gwnDEMMMa7iCSk1Mjo/AJXBrfj/5fNkGgM3SE3vov/P2/w3ugEQ d+G+YzKACXDQKSTAw4q6KcrNaFYx6T+33esWqGoWwOC2CIB+6jGWiRDN1TTCUs/1Ey+Y 0uGg== X-Gm-Message-State: AOAM5322oz+op/l1qLS/FZ3bITZeTOEIchqcy9cjXoilTSPkTavBUmv5 notJLTvVIkMIRR+XWYH+2yQ8CUtiniOu9A== X-Google-Smtp-Source: ABdhPJw18uBv9CCZp6QdS97mf9wFRJ3v72iwgJVAvkSPTR0b+aGMbTLr3a1AxvWi4cvWW8VeqK7ewg== X-Received: by 2002:a05:6402:430f:b0:42e:2a86:abaf with SMTP id m15-20020a056402430f00b0042e2a86abafmr25408885edc.194.1654589455481; Tue, 07 Jun 2022 01:10:55 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id n9-20020a170906700900b006fe8ac6bc69sm7377562ejj.140.2022.06.07.01.10.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:54 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 05/23] microblaze: Switch absolute branches to relative Date: Tue, 7 Jun 2022 10:10:22 +0200 Message-Id: <426be405890fa76ca2125942b0480700b82a3238.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean There is no reason to use absolute branches and use just relative. This change helps with moving binary to different location and start it from there. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 645f7cb0389d..9e00eef1f4b6 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -29,7 +29,7 @@ _start: /* Call board_init_f_alloc_reserve with the current stack pointer as * parameter. */ add r5, r0, r1 - bralid r15, board_init_f_alloc_reserve + brlid r15, board_init_f_alloc_reserve nop /* board_init_f_alloc_reserve returns a pointer to the allocated area @@ -41,20 +41,20 @@ _start: /* Call board_init_f_init_reserve with the address returned by * board_init_f_alloc_reserve as parameter. */ add r5, r0, r3 - bralid r15, board_init_f_init_reserve + brlid r15, board_init_f_init_reserve nop #if !defined(CONFIG_SPL_BUILD) /* Setup vectors with pre-relocation symbols */ or r5, r0, r0 - bralid r15, __setup_exceptions + brlid r15, __setup_exceptions nop #endif /* Flush cache before enable cache */ addik r5, r0, 0 addik r6, r0, XILINX_DCACHE_BYTE_SIZE - bralid r15, flush_cache + brlid r15, flush_cache nop /* enable instruction and data cache */ @@ -75,14 +75,14 @@ clear_bss: bnei r6, 2b 3: /* jumping to board_init */ #ifdef CONFIG_DEBUG_UART - bralid r15, debug_uart_init + brlid r15, debug_uart_init nop #endif #ifndef CONFIG_SPL_BUILD or r5, r0, r0 /* flags - empty */ - brai board_init_f + bri board_init_f #else - brai board_init_r + bri board_init_r #endif 1: bri 1b @@ -289,7 +289,7 @@ relocate_code: /* Setup vectors with post-relocation symbols */ add r5, r0, r23 /* load gd->reloc_off to r5 */ - bralid r15, __setup_exceptions + brlid r15, __setup_exceptions nop /* Check if GOT exist */ @@ -318,7 +318,7 @@ relocate_code: /* Flush caches to ensure consistency */ addik r5, r0, 0 addik r6, r0, XILINX_DCACHE_BYTE_SIZE - bralid r15, flush_cache + brlid r15, flush_cache nop 2: addi r5, r31, 0 /* gd is initialized in board_r.c */ From patchwork Tue Jun 7 08:10:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639846 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=su56TKoH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNQD3gJ7z9sFs for ; Tue, 7 Jun 2022 18:12:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB6D084361; Tue, 7 Jun 2022 10:12:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="su56TKoH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AB0084304; Tue, 7 Jun 2022 10:11:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DFB42842F6 for ; Tue, 7 Jun 2022 10:10:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x632.google.com with SMTP id m20so33505232ejj.10 for ; Tue, 07 Jun 2022 01:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f2gtBFhkvDy4UZ4jM3qsdSVsUElzixg31Uw+z0mN3ps=; b=su56TKoHOufb0OzTYkHwtX2ROxoZ7r+KNQoYMAeinOup3xDJIC1JTyROEb6bpz9NdI GL+2XQo/RWCN4C2Vej6hsQKzLZyKC1dTTbivKB+FZufmTVf5jsGUZ0hRGFkfS00M5HlJ syVKwJ+2F5lZe8RNkxKD86YKfLpU7Pa6yHPwgCEFEehsjjTytSlUAE1kir/Cu4MS60GU 2tkeb1cxTodD0bgJjvj3hlTa5+3Lgbz8sTkPKDSUVKc2ZOEjUdIEbR64jIf1RNNq7WXH UG51mVhuytulaxTcSG0IPvxrxE+lPZ0+hZpRx7imnDqsb55i8WE/ahVdqrjhwVqfWDn8 tAgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f2gtBFhkvDy4UZ4jM3qsdSVsUElzixg31Uw+z0mN3ps=; b=0ElxnyBTGxTI4mrsubeXx4DvyYDqjMxUhzO+6Dg8H56u8T2HLlfQf5tRqPVjOxaxEu Kh6237BsIm4S5/eS91FX6ZU9Ax+FC/ChF2RFnpQ7BTWUVHvqUQALR6eA2T9Te/3pRTwV VmU96kCG71vjGKGqyieS5tKDfmgmtsF3Yj7nzrPYLfUKk9KAjm5hYWdVK+Cn5tuyEJna lHDOeqOhewYMXABz49ZUFjHvwFuPlNzfL29e4AW6HTTzAUaniTvDmbAiu9h/KCXVQK2a /7w3nPUx0/Y4eapWPU5s2GS0W4RRgzJWWfcpasNRoX2bhaZR2wAxNuRHJwZNtUhdtbq3 6vHg== X-Gm-Message-State: AOAM532vIjr32WJjdyDLt4ZmvZtYnfN/VvMZWsG4CqomnTz5BUYyrWqE Js0G+rj63op6VThY3bhMZRPhRVJbYcR20Q== X-Google-Smtp-Source: ABdhPJyx+s4ES8xKNfVO7QBRP7wjDNTWyKdxTw9gfcSMjrIeTf9mfqB49JAUaSqBp6/4ivOWkc00yw== X-Received: by 2002:a17:906:99c5:b0:6ff:4c8f:6376 with SMTP id s5-20020a17090699c500b006ff4c8f6376mr25618840ejn.328.1654589457894; Tue, 07 Jun 2022 01:10:57 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id p19-20020a056402155300b0042617ba638esm9961933edx.24.2022.06.07.01.10.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:56 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 06/23] microblaze: Fix stack protection behavior Date: Tue, 7 Jun 2022 10:10:23 +0200 Message-Id: <71e4b724b703ad87983e599a7a32cb80e2ee2c0d.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean When U-Boot starts stack protection can be already enabled that's why setup the lowest possible SLR value which is address 0. And the highest possible stack in front of U-Boot. That's why you should never load U-Boot to the beginning of DDR. There must be some space reserved. Code is using this location for early malloc space, early global data and stack. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 9e00eef1f4b6..715ef37b39d9 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -15,8 +15,9 @@ _start: mts rmsr, r0 /* disable cache */ - addi r8, r0, _end - mts rslr, r8 + mts rslr, r0 + addi r8, r0, _start + mts rshr, r8 #if defined(CONFIG_SPL_BUILD) addi r1, r0, CONFIG_SPL_STACK_ADDR From patchwork Tue Jun 7 08:10:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639847 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=jP48rodj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNQT4b22z9sFs for ; Tue, 7 Jun 2022 18:13:05 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDA3B84369; Tue, 7 Jun 2022 10:12:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="jP48rodj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2044C84343; Tue, 7 Jun 2022 10:11:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12E04842FD for ; Tue, 7 Jun 2022 10:11:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x635.google.com with SMTP id fu3so32076058ejc.7 for ; Tue, 07 Jun 2022 01:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aJ32AvSz8RUKUp121yKRoe0YQf6xa+bUdTdlgCp+uEM=; b=jP48rodjzKNMJ85VZRm1aLwk/J3tsnwU7yW+/S/190/iAmTwgKIHB1PHX/OzLg/low sFE9aoxba4fGfPuO5j87pqWuqNCrygFrniKG4XVvMnxEk2Rcdf+971L2nxB8d3HAi/2f 5Ytmg8UFalFu5hKXR9j+y3NcGRw7FbmjmGYRpBAmONyV8PZayszuriYKoMhGovjkrky9 dBdL6AHXyIuD/2KFo5SLfG0Yy/2t97hth828TYkGJkTuQvffsxDCXr4YWHTKeYOQtaZ2 h4PVQfFvaNwhWJ4waYOwmZ5zKUe4HYsmLlNGxWYCts+QOi4Whn2WiMk6cDGPYNKMYjcs 9Xrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aJ32AvSz8RUKUp121yKRoe0YQf6xa+bUdTdlgCp+uEM=; b=S4WhNRtlwnDuczRCnGZksH9vuPeWVnL8fZ/cbz2pdRwSarH6QPUR4aR/VFXv9dZIrY 9s7bLIGKzD071k3CtMSsG+kJlpprrn01B5F4r7HqZ/d+ISgwaiZBoi1VmwlbM/GqQ0Pe R9GEZg57ozq9pSF1aIxCSIvZldfc82xBSGy3vhIvrhZuDTEQzfs99UiWVhID/Y+n3l5z bNkdwibiLe9iHTZGHJSfu2pTpp5XRSThOkKybf7T9Q+y9Bn5ovhzcUPhqGmzaQIrvP4c FUZsY9s3oK2lgt9TRFiOTrnMzYRn/82XvTUtZ5UQJLri/CRj8E5pSJuhycWko6/L60BN Dhrg== X-Gm-Message-State: AOAM533x7by5b7ikWAr+VO2rl/jXQIexT12pBg/PEjrxNSHVhhcwuGdR HWp1G7AK7LQBwKM8CMBDVoP8bpL54O5A2w== X-Google-Smtp-Source: ABdhPJz7vnCYTUN4a4yq5BXk8SDSarz8kZKxy2DuipefXkTJQVpfnz7P5XFBCtXcdP/a9lTu5225Nw== X-Received: by 2002:a17:907:1c0b:b0:711:cc52:2920 with SMTP id nc11-20020a1709071c0b00b00711cc522920mr9921047ejc.301.1654589459503; Tue, 07 Jun 2022 01:10:59 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id i23-20020a1709061e5700b00708a2ae7620sm6896893ejj.67.2022.06.07.01.10.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:10:59 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 07/23] microblaze: Fix early stack allocation Date: Tue, 7 Jun 2022 10:10:24 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean CONFIG_SYS_INIT_SP_OFFSET macro place stack to TEXT_BASE - SYS_MALLOC_F_LEN but there is no reason to do it now because board_init_f_alloc_reserve() returns exact location where stack should be. That's why stack location is calculated at run time and there is no need to hardcode it via macro. This change will help with placing U-Boot to any address. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 2 +- include/configs/microblaze-generic.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 715ef37b39d9..1acac5faf428 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -22,7 +22,7 @@ _start: #if defined(CONFIG_SPL_BUILD) addi r1, r0, CONFIG_SPL_STACK_ADDR #else - addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET + add r1, r0, r8 #endif addi r1, r1, -4 /* Decrement SP to top of memory */ diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 663837f33dc4..60ceb2c817e9 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -18,10 +18,6 @@ # define CONFIG_SYS_BAUDRATE_TABLE \ {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400} -/* Stack location before relocation */ -#define CONFIG_SYS_INIT_SP_OFFSET (CONFIG_SYS_TEXT_BASE - \ - CONFIG_SYS_MALLOC_F_LEN) - #ifdef CONFIG_CFI_FLASH /* ?empty sector */ # define CONFIG_SYS_FLASH_EMPTY_INFO 1 From patchwork Tue Jun 7 08:10:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639849 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=wEL2Qmwj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNQz5knLz9sFs for ; Tue, 7 Jun 2022 18:13:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0FDAD84328; Tue, 7 Jun 2022 10:12:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="wEL2Qmwj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87E0784314; Tue, 7 Jun 2022 10:11:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AF77E842FA for ; Tue, 7 Jun 2022 10:11:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52d.google.com with SMTP id er5so21885515edb.12 for ; Tue, 07 Jun 2022 01:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vu7G09FGx/Tc/j856cGMWjOg0IZCEzJ5Kc7PFY6nkf4=; b=wEL2QmwjeoYzn7CfZldJ4i/BF7qT3qvXkv9F1gvJ+NeTK9XAVMn1A1hyKHVGKqfgcG tA6G1r4hC+F23zCKuCzBxpVp2wm3oKQcVKk98cEBkpI3UI/wYuOcknox5G4CmIeTL515 VCebKJsVyxAsKwlVQzHlufcgfcCqHI6H24rLVUF7+yCZzSXCAYfoMgoBSbCuJ9/tUVWa MHTrnR3TAMAt7+DOcYfppJwYN9T5VWm5RAMnQGKqBkA+UIIyimvqa2hvJSqlEncNglUp 7c0jNCIsrqRpzWp/zNCTKxsLJltP8kDT2wHK+Rl3mllbclducxqZlCcV8SivBGTXE4Yj r2RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vu7G09FGx/Tc/j856cGMWjOg0IZCEzJ5Kc7PFY6nkf4=; b=G3zb1d9uQCHEUabH9BGFM3Aq3Ablb34nMSdPfxRhA8BxK8NPeLlHyqea5ettXkR1B7 L/mQ40Paenpuuz3k8ftMVshj2SL5h4Yn/G7Z7uQex6O3Rr1AEqcLdOmnlTEMGZ8p6dLk Lm2GgaJ5LaSsty9Di3dCcnLQ/oTHNzVE7iS9Gf53c7k/mxl3zChtiqqsKXA6oj5Dy7Zx aFAvvIwJooRK+SsHwEV+xzyGOxNXSeyX0KmcyzLjfgBYV4hnHTzoYbI/d4Q+ptfA+uZG NaTsP8toyEr0q48dmtT6KaD+EdkXXHAuTAYkwffFliUfc3JOBCtqel011Rm28GvN4XDD ruzA== X-Gm-Message-State: AOAM531vtKY+2jgWMaVZf1gKfyLS6QAnpMU988996SZ9WbOXUipu/HLJ qPquOtQ0VbuuA23BJREjaVnVm/7RzcZzfw== X-Google-Smtp-Source: ABdhPJzt6UwrdaLkZ1ih4CjyEt4sJGpz+q0DGPhCZygpf1HwjtN46ngqnQ7/ZGslLwR7ao8accAcBg== X-Received: by 2002:a05:6402:d0a:b0:425:d455:452 with SMTP id eb10-20020a0564020d0a00b00425d4550452mr31543200edb.259.1654589461166; Tue, 07 Jun 2022 01:11:01 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id u17-20020a056402111100b004316f94ec4esm1961233edv.66.2022.06.07.01.11.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:00 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 08/23] microblaze: Remove CONFIG_TEXT_BASE from code Date: Tue, 7 Jun 2022 10:10:25 +0200 Message-Id: <47bc79209c53fc690cab5a9e4a8d722d9bef9853.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Use symbol instead macro to find where U-Boot starts. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 1acac5faf428..205d5f384c38 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -142,7 +142,7 @@ __setup_exceptions: swi r2, r4, 0x0 /* reset address - imm opcode */ swi r3, r4, 0x4 /* reset address - brai opcode */ - addik r6, r0, CONFIG_SYS_TEXT_BASE + addik r6, r0, _start sw r6, r1, r0 lhu r7, r1, r10 rsubi r8, r10, 0x2 @@ -285,7 +285,7 @@ relocate_code: /* R23 points to the base address. */ add r23, r0, r7 /* Move reloc addr to r23 */ - addi r24, r0, CONFIG_SYS_TEXT_BASE /* Get reloc offset */ + addi r24, r0, _start /* Get reloc offset */ rsub r23, r24, r23 /* keep - this is already here gd->reloc_off */ /* Setup vectors with post-relocation symbols */ @@ -323,7 +323,7 @@ relocate_code: nop 2: addi r5, r31, 0 /* gd is initialized in board_r.c */ - addi r6, r0, CONFIG_SYS_TEXT_BASE + addi r6, r0, _start addi r12, r23, board_init_r bra r12 /* Jump to relocated code */ From patchwork Tue Jun 7 08:10:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639850 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=CB2DLyJJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNRC1QxPz9sFs for ; Tue, 7 Jun 2022 18:13:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C69A84382; Tue, 7 Jun 2022 10:12:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="CB2DLyJJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3602C842FE; Tue, 7 Jun 2022 10:11:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EBDAF842E6 for ; Tue, 7 Jun 2022 10:11:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x629.google.com with SMTP id bg6so13735465ejb.0 for ; Tue, 07 Jun 2022 01:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a6NGRU3FH7XVMMyQi+uj3rlFifrldTr3wGEgpxETKsg=; b=CB2DLyJJUbKf4TJkn5TXBVc1/aJXDUBkQQBnufqoACPNQnjIGjC7Y7X/xsqSGpWwfs cg0EDCochv0IhGhzi3BHbppzmVNgABnOVyQOhHZnIV/3z4SZ7vUgxAKYjvcdt44xoQ3Y juPGVz+IwHxCq+c73zD6zx+o7R6gBIGkFT+4YAm4d5MPxItGCLlxmQX35YS0KexsrARd ItJ8VcxVI+JpjoKonQayFkO0+AvY2ufSncZnt1vY74nmvTurJziW1aBrQBmMG8Y2/FyK MRcpyPKcd0baeoGaO7L0impj7s7Q9xFhd1P5Et6JfuDB9oHZ157cTlBevPCUN+lJkFH8 ynzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a6NGRU3FH7XVMMyQi+uj3rlFifrldTr3wGEgpxETKsg=; b=ap9dSYdrtG6tpzsA1t11bm1Qxo7Bk58FZ+i8gqmq03TYnH9EZrlsTbh69rYTdaHpn0 1D67VoFXS6cz5BkX3yCZwncfOK5MA++iCuQ8qwPS/NmUfJYX4B4DAdK3KeESQTNdRUUh uvg71EhRvqST2qyLozxMF6slNrkj4YC8jKABmR1RXuGvKf33priUsdyqge+JF6loB9P0 UzJ63nRyx+hOVJee5gjEBgOCZ1dLv7hme5KiYeauYKqE1whZuhpj9MOHhSjx1NHA5H/t QBPwgzFYEtK+ieBD93AYitwavT9J8zmrdFaF+vfBUd7iYvjTqM4X9aihxAmIwz7tjhHa gfYw== X-Gm-Message-State: AOAM531dQ+HThhRmYs34i4kXLM1H23Q1kiA8wBxc34nK2TuuxjmQ+UlI AToAbm054rJ+M8VxTqh8tFk9XVAq2EIfmQ== X-Google-Smtp-Source: ABdhPJzzgkvKnHSsu/QdXvj/GL8OsIqLfatjrBnnwrOD3pfMAYe8rkrNa6ACrDsnMdvi61ceLgsb/A== X-Received: by 2002:a17:907:7f06:b0:6fe:b81f:f885 with SMTP id qf6-20020a1709077f0600b006feb81ff885mr25339724ejc.621.1654589462696; Tue, 07 Jun 2022 01:11:02 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id d5-20020a170906344500b006fee98045cdsm7335974ejb.10.2022.06.07.01.11.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:02 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 09/23] microblaze: Fix typo in exception.c Date: Tue, 7 Jun 2022 10:10:26 +0200 Message-Id: <974baacf1bf8018527b53168cc806e4a3b3ea084.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Trivial fix. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/exception.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/microblaze/cpu/exception.c b/arch/microblaze/cpu/exception.c index d3640d3903b8..9414776afa7f 100644 --- a/arch/microblaze/cpu/exception.c +++ b/arch/microblaze/cpu/exception.c @@ -16,7 +16,7 @@ void _hw_exception_handler (void) /* loading address of exception EAR */ MFS(address, rear); - /* loading excetpion state register ESR */ + /* loading exception state register ESR */ MFS(state, resr); printf("Hardware exception at 0x%x address\n", address); R17(address); From patchwork Tue Jun 7 08:10:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639848 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=M5N7ZetB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNQk6BLRz9sFs for ; Tue, 7 Jun 2022 18:13:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53CB9842F6; Tue, 7 Jun 2022 10:12:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="M5N7ZetB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D014A842FE; Tue, 7 Jun 2022 10:11:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 77C2E842F6 for ; Tue, 7 Jun 2022 10:11:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x633.google.com with SMTP id y19so33564785ejq.6 for ; Tue, 07 Jun 2022 01:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZpDBkYAuzeynrVGTxmz2ysEfWK11dHuWlOYJV8LkqKY=; b=M5N7ZetBzxAkbCmGU3mf1Br68ChKNyb/Ds/bZzijdrEAee4ZVX0CPBmq4Zn4thWVSp Va4KXJ2GTdPD+1p933TWmBI1jzm+GH5ypPybO2oJr+775nm/5XfatIyvgB/hy2bdlc6e c/4wnBl713qiP5ac8IkXMyOrGnScTC93v1lrWUulOo83ke7u/xHZpoe0/e6FmFzQ3HD+ x57B/6LLg8bSJ1+pzNPcfhA7FRCMTm/3hmqYdNj1suB6/bktGn1DRXNj0yi0+AJs9FJ5 bzmvOSx7KTv+h7Ue3/9b5avOJ3z8VT1LkNzYBS0KrUBffi4jf8LsUb5WRBY0X8hAgjgA EWFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZpDBkYAuzeynrVGTxmz2ysEfWK11dHuWlOYJV8LkqKY=; b=k2mX5A/eetmFte805BaGYkEGlrmWoH5zFq44NAi+TOSHkyP3ObvKBpnRf5VyiOsIrN Dm7fAAkt9C4ZohcJx7phl7fjCxuTnJ1nAh+1IVTFYeXtpTY6qdDHhwm2zm5Pb6dT6JS5 SXx+8OqqVeenHY1oc8ARfiR5ppsbZQDgeER+L+Ov9SPu62OGef9KMyUBAIkSUl4WfSqJ ugHAx28GX1+YrlDT1ihG2UWsDsdKL3yMC270LbTaqOCQ+coO32prHQABlWFiZMk9pwhT /vZPtJmMGmiuJIpXaVXg1Sy/CD4IYxJQeFc84s3zVFpRCSSIsy+ARNuuRbzHZdFoZZmt HDvQ== X-Gm-Message-State: AOAM533N/75UFNa0GoXQtOH+xISSRfx9yeX+7chztYLBTNKJbqNbYG1z bg4TvwS3U4Ps3Epa6QVhzx+sruiVNYTQOg== X-Google-Smtp-Source: ABdhPJyPkwYExvIF0V36dhowKhKMpmxmfge4hDzRBDo5uacWGKLUx1o6MtlWPNSKGnMZWhZt+yNtBQ== X-Received: by 2002:a17:906:5d06:b0:710:ad3d:2f31 with SMTP id g6-20020a1709065d0600b00710ad3d2f31mr14475039ejt.509.1654589464480; Tue, 07 Jun 2022 01:11:04 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id t20-20020a1709066bd400b006fea3702e56sm7248033ejs.79.2022.06.07.01.11.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:03 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Daniel Schwierzeck , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v2 10/23] mips: Move endianness selection to arch/Kconfig Date: Tue, 7 Jun 2022 10:10:27 +0200 Message-Id: <8b557f84ee404a580915a59a0fac111efc575202.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This option will be used by Microblaze that's why move it to generic location to be able to use it. Signed-off-by: Michal Simek --- Changes in v2: - new patch in series to solve Kconfig warning arch/Kconfig | 22 ++++++++++++++++++++++ arch/mips/Kconfig | 18 ------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 12de8a11650d..4851300e9bbe 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -447,3 +447,25 @@ source "arch/xtensa/Kconfig" source "arch/riscv/Kconfig" source "board/keymile/Kconfig" + +if MIPS + +choice + prompt "Endianness selection" + help + Some MIPS boards can be configured for either little or big endian + byte order. These modes require different U-Boot images. In general there + is one preferred byteorder for a particular system but some systems are + just as commonly used in the one or the other endianness. + +config SYS_BIG_ENDIAN + bool "Big endian" + depends on SUPPORTS_BIG_ENDIAN + +config SYS_LITTLE_ENDIAN + bool "Little endian" + depends on SUPPORTS_LITTLE_ENDIAN + +endchoice + +endif diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9b62764f4fe6..2e0793a7a7b8 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -180,24 +180,6 @@ source "arch/mips/mach-octeon/Kconfig" if MIPS -choice - prompt "Endianness selection" - help - Some MIPS boards can be configured for either little or big endian - byte order. These modes require different U-Boot images. In general there - is one preferred byteorder for a particular system but some systems are - just as commonly used in the one or the other endianness. - -config SYS_BIG_ENDIAN - bool "Big endian" - depends on SUPPORTS_BIG_ENDIAN - -config SYS_LITTLE_ENDIAN - bool "Little endian" - depends on SUPPORTS_LITTLE_ENDIAN - -endchoice - choice prompt "CPU selection" default CPU_MIPS32_R2 From patchwork Tue Jun 7 08:10:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639851 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=w9AGc+11; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNRQ2Rx4z9sFs for ; Tue, 7 Jun 2022 18:13:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE9C984303; Tue, 7 Jun 2022 10:12:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="w9AGc+11"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E24B842E6; Tue, 7 Jun 2022 10:11:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ED7F384300 for ; Tue, 7 Jun 2022 10:11:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x635.google.com with SMTP id h23so22487988ejj.12 for ; Tue, 07 Jun 2022 01:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/b6mse38NIezFtyoVeKQfmkJIvU5NbTfMUMmgb4dzjE=; b=w9AGc+11xszZihDL/OG/qzv9a8YU6gfmSepTWAf0LwmVQHS10nEGVwFqxD2KnBH1Cg mxup/KTTirGXRlOOzgY8XRemJg+84/02oNiGCv9J4WjOysekSlYOEskbrf1UCGpiQzBd CEOuraT2bvucCfIobU9A71pQzxs0wIAw3vrro5K9n3PL4YezmQdzI5q0Io/LKPWPpftd /WOcuMG2KyElh87MyOKsBWcgU/MOCczp9FezLsKuYQxiQoJpB8UaZs7ox1GqRpVeX/p/ XBeJSek7mDzioD6GOK5+Im8+RDDzxYYNG8uxbLLmGIHRqHubQi0aeVmtzDqjhCPFJxaV qTRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/b6mse38NIezFtyoVeKQfmkJIvU5NbTfMUMmgb4dzjE=; b=7g/P6O7q2OYIOHSVmk2s9wkP9TQIwGcwqFhAw7PkwQh0ljgRG+zvJJPiSuGd0ypbqr RQcPBVjao5r2xl5X+kziDGTQITcCzpc0XyVCbtF9N7xv/71RVN+chA58nKy3xTtPDRDL O/u5BR7/nkG+gOCu91NMMhYGz0kT7Q66aO6xLAvip180wGi4ieIu7lCZiEhISQViilJt HayB73LkYFmAWETgAijlyVXsNq1LQ3n+QI9JsPT1xlGbkYibR5RW4G6F4sMt7yeY11xG K4qHzWi4/FBOoTZt7fBmJ+MhljKJ6rVY3zCPaQRULC91B49jk/pvPxtdJRtJD/fp7NN0 DQZg== X-Gm-Message-State: AOAM530uyWYwv0LPlcszeCqAH+wk61Qdk4tDCZNAsw0GemoDKp17lVO3 5UYCr2ogpXzD+HGxl8CdHRTnZZY+kqKRXQ== X-Google-Smtp-Source: ABdhPJxt/wyFEJXw7h8JAscZmbzeWTZm43ID9sGBXSXEztR6q2Hd+Tns+7XWxF/8V2pd7QpUv8HTjg== X-Received: by 2002:a17:907:7fa9:b0:711:d214:36cd with SMTP id qk41-20020a1709077fa900b00711d21436cdmr7085672ejc.600.1654589466386; Tue, 07 Jun 2022 01:11:06 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id fg24-20020a1709069c5800b006fe9ec4ba9esm7152494ejc.52.2022.06.07.01.11.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:05 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v2 11/23] microblaze: Enable REMAKE_ELF Date: Tue, 7 Jun 2022 10:10:28 +0200 Message-Id: <321cfddf6dac18f578de6fbd57e103ddb94e0de9.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Enable u-boot.elf recreation from u-boot.bin to prepare for removing manul relocation. Enable option for big endian configuration but it is not used too much that's why it is completely untested. By supporting this system there is a need to define LITTLE/BIG endian Kconfig options to pass -EL/-EB flags. Full command line for u-boot.elf recreation looks like this: microblazeel-xilinx-linux-gnu-objcopy -I binary -B microblaze \ -O elf32-microblazeel u-boot.bin u-boot-elf.o Signed-off-by: Michal Simek --- Changes in v2: - Fix endian selection arch/Kconfig | 6 +++--- arch/microblaze/config.mk | 6 ++++++ configs/microblaze-generic_defconfig | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 4851300e9bbe..02de32f9c77f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -448,7 +448,7 @@ source "arch/riscv/Kconfig" source "board/keymile/Kconfig" -if MIPS +if MIPS || MICROBLAZE choice prompt "Endianness selection" @@ -460,11 +460,11 @@ choice config SYS_BIG_ENDIAN bool "Big endian" - depends on SUPPORTS_BIG_ENDIAN + depends on (SUPPORTS_BIG_ENDIAN && MIPS) || MICROBLAZE config SYS_LITTLE_ENDIAN bool "Little endian" - depends on SUPPORTS_LITTLE_ENDIAN + depends on (SUPPORTS_LITTLE_ENDIAN && MIPS) || MICROBLAZE endchoice diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index de5b97e719cc..3e84a832fc12 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -16,3 +16,9 @@ LDFLAGS_FINAL += --gc-sections ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC endif + +ifeq ($(CONFIG_SYS_LITTLE_ENDIAN),y) +PLATFORM_ELFFLAGS += -B microblaze $(OBJCOPYFLAGS) -O elf32-microblazeel +else +PLATFORM_ELFFLAGS += -B microblaze $(OBJCOPYFLAGS) -O elf32-microblaze +endif diff --git a/configs/microblaze-generic_defconfig b/configs/microblaze-generic_defconfig index c0f5d4c9a1cf..c2d25ea460b2 100644 --- a/configs/microblaze-generic_defconfig +++ b/configs/microblaze-generic_defconfig @@ -18,6 +18,7 @@ CONFIG_XILINX_MICROBLAZE0_USE_DIV=1 CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=2 CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y +CONFIG_REMAKE_ELF=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_BOOTDELAY=-1 From patchwork Tue Jun 7 08:10:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639859 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=U5rCLQg2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNXJ0dDHz9sFs for ; Tue, 7 Jun 2022 18:18:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B830D842F2; Tue, 7 Jun 2022 10:17:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="U5rCLQg2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CAFC84343; Tue, 7 Jun 2022 10:11:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1F8788431B for ; Tue, 7 Jun 2022 10:11:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x632.google.com with SMTP id m20so33505232ejj.10 for ; Tue, 07 Jun 2022 01:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RrnX52sgjLDO78ey3VB3yR6CYldltte0wSF5rLl5zU4=; b=U5rCLQg2C6TNVxJ2uxHU2/f0iA4aY8rSV3AEm0N1ctt7/B/o+gBWL62RhLs1td82ED 019VAnOhKddJH5WDeciivY4pqrq9g0lOC0Ul8FSBC5sbsneoyTmWbkx7xDUE2xL1ssmK TnwqOPR+D0fUgxCfpggwp9Dpp1IbQjHXIRj6WsL05PLSk0I/sA/maM+3kfzB0kpBCEIT thQsUU6SPuIdg2Sv+/p2XAJlrGk37wl6Ybv7zrl6BlVJu/0LnnlQfdcXvs/mCUzjEPJv M5P/OLcW4vRFCZgA7o4MHRB/gSImipX15qsr4EJY/FlJptxQrWq72YrDeW6mehMB4dRo JH9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RrnX52sgjLDO78ey3VB3yR6CYldltte0wSF5rLl5zU4=; b=f43hnPeCTxejTRE1MltqVWNndxpFD+XnSlk1IutO5gYdZPxshJ1JDP+CwhmQUJDsyr ECD+lkwg+FBCKaZZBKu0bw21HKYmHfHI5abGAkLcy4zL3SnUuYFEEQg4iHCIvzrMAd00 QUqxKJtD8FupbtsGtTKhFCaTgDAzRFdbv03pD43EmhZwYE5yl0vFbRrvWGqKP4DN0XxI 02IEV12TBVr93D7LVANbAJeWyZ9aCIH0H6ySVfspZ9lMJuY3f0Evztu4xojbBHoA15PQ 9EXoD9YDmVN38oeIILJX+6mOsOHVk6va9TTF+sSGyvXLE4GB6+MI+n1gnrh72/KW4IdF qOxw== X-Gm-Message-State: AOAM531NAHXn/jYOtbRWsWDBX3F6IP3AinxkF8ec+RsmgrmTfKF6guEN YIUGfSkhS07UtjhZW47ajlCFMTC14TBhog== X-Google-Smtp-Source: ABdhPJxZgJlTcsXi+l+NdnTjqX5q1uT5b5VwYw2+riQ9ebMGMg1S6PkCxd0C9/XowmD7aIfeX50XAg== X-Received: by 2002:a17:906:dff9:b0:6ff:2f22:7d0 with SMTP id lc25-20020a170906dff900b006ff2f2207d0mr18181942ejc.198.1654589468626; Tue, 07 Jun 2022 01:11:08 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id m3-20020aa7c483000000b0042de29d8fc0sm9800890edq.94.2022.06.07.01.11.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:07 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 12/23] microblaze: Separate code end substraction Date: Tue, 7 Jun 2022 10:10:29 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Follow up patch will convert symbol handling that's why it is necessary to separate logic around symbols to special instruction. It adds 4B for new instruction but it is worth to do it to have code ready for for full relocation. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 205d5f384c38..a35d8d8ea29a 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -273,7 +273,8 @@ relocate_code: add r23, r0, r7 /* Move reloc addr to r23 */ /* Relocate text and data - r12 temp value */ addi r21, r0, _start - addi r22, r0, _end - 4 /* Include BSS too */ + addi r22, r0, _end /* Include BSS too */ + addi r22, r22, -4 rsub r6, r21, r22 or r5, r0, r0 From patchwork Tue Jun 7 08:10:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639852 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=tKe7EoUW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNRg3qqKz9sFs for ; Tue, 7 Jun 2022 18:14:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C086C84399; Tue, 7 Jun 2022 10:12:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="tKe7EoUW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F688842C2; Tue, 7 Jun 2022 10:11:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 34CB0842FD for ; Tue, 7 Jun 2022 10:11:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x530.google.com with SMTP id b8so5226734edj.11 for ; Tue, 07 Jun 2022 01:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/kdUkM4vRdr3zudomb8GJz5tx+uPnjCb68Ywdi5Ke0U=; b=tKe7EoUW3KsTm6HL7qhsyPm85XfGQCmcfoj7K1IekSTOTxVKb/ghq0Yo3zYFO58AqG zlNtLicKm8oEeR04LAUirQfWeSUh69K+8g7IaQ0S5LdY3RYcBRMm0WXe1L6E5WTa5qjS L84tTwxmR2KNbxDEUgnIUZckEf3v0KLLShhPh1ldhoCHKgrJZ9FS6jfiDQlhkg4m26eq gYEwODMyIpr8G4AFI/81IqQMhkAzWwsK9I6Q4wVwMQHlYvvFbF5vUN3+Cc7ttGDjR4qr 35L0qZ/bODlgdD5L0pvfo6SIF+lvSdzFSUe+T7SJ7UahvFt1QQO7FLP/oEbMBJJclGuD n0EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/kdUkM4vRdr3zudomb8GJz5tx+uPnjCb68Ywdi5Ke0U=; b=t2Pe0TZCKs3tfaooR07AWh5kUE6m0I8RAx7hAqdSIbVNF/HKFgKtqjrOI6M9TjPJKD rrO9cD5Lvx6crRGGZj3UAtPatKtvV55C3MjVQMv0fBy9G3sJxa5I3RkDz0MW9iHlm8SH tuFJ84WOvADvgPVAzF7J47Zd7NReFMh9bBtioXVQiZXbEOea8K0GN+ho/1EqiHPZyTy8 j4bi+YN3l+zbginUimQMe6gBpQLa0+QzGP7sAOXCBDGT7tc4d7VTS8GN7dxKJzeKLDur JJOvFIv8uBbDvv5CdE0oOU2xtA5Ix40FaF4P+6UOnR6t2FUcnUIwvN5Oo0zj1h005SGc UiKg== X-Gm-Message-State: AOAM531mFOISG1X2qUQp5gFFog0x0yUVV+pLouoHiw5jz8Q2H8GmosDs wQ8w6ISYFya61+guD4qTgHz12my4hLCmQA== X-Google-Smtp-Source: ABdhPJz0IVIqxh8ZbsalRpmH2Ws8dbstY05G20wN3AEJplmrmC8ZzU6IDbnDcB+KPtgt2k6P8aFtgA== X-Received: by 2002:aa7:c744:0:b0:42d:f68f:13de with SMTP id c4-20020aa7c744000000b0042df68f13demr31556144eds.294.1654589470383; Tue, 07 Jun 2022 01:11:10 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id c24-20020a056402159800b0042617ba63c2sm9939331edv.76.2022.06.07.01.11.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:09 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 13/23] microblaze: Change stack protection address to new stack address Date: Tue, 7 Jun 2022 10:10:30 +0200 Message-Id: <959f673144ca94257867e31f559618195cab4a04.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean SLR low address is still setup to 0 that's why only high limit should be updated. STACK_SIZE macro is present and could be possible used for low address alignment but it is not done by this patch. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index a35d8d8ea29a..2aae4a0b7ccb 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -268,6 +268,7 @@ relocate_code: * r7 - reloc_addr */ addi r1, r5, 0 /* Start to use new SP */ + mts rshr, r1 addi r31, r6, 0 /* Start to use new GD */ add r23, r0, r7 /* Move reloc addr to r23 */ From patchwork Tue Jun 7 08:10:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639853 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=O8J1kPKl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNRw116Nz9sFs for ; Tue, 7 Jun 2022 18:14:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5824084393; Tue, 7 Jun 2022 10:12:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="O8J1kPKl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5318884357; Tue, 7 Jun 2022 10:11:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1566F84304 for ; Tue, 7 Jun 2022 10:11:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x62e.google.com with SMTP id kq6so20536308ejb.11 for ; Tue, 07 Jun 2022 01:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+eNM808sVhgauYAKAjbuvO5ZCuz5b3O7uKaEwzY46FQ=; b=O8J1kPKlBDA7Vr1scAogpQ0ArmO37QoYfmM7r1JxlgRoBEduafCh/BA5ltUznbc6Gw sW+Qb5It6OJUwESV7B+xrmVKbW+BPWnM4CX5E7xL4/e249kb/Bpp54dhgqhxaTvaSF5m n4+fMl2cT55g78nXm6udgp6cAUv629kyUCXmGFrbu/8eDP5t+9gB1P4Jz6/aE4N/oJsv lIb7S8IerCRthFddaDTa2nUm9TKdUSfsO3HKINPfk8BIz2Fu6au1MpGwIZizWCDsNdRf bD3WCmZlMGLkI+oQIn/Svs9pBeiSvwos04CIzyiQarqKrwmJCYDnbQpOVoPY2Ay+obv1 Br0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+eNM808sVhgauYAKAjbuvO5ZCuz5b3O7uKaEwzY46FQ=; b=p0UMUetiXIioASJLqHocd2YsTh9pbKh3S3Cx7/jsxXzLO13pR+2qzquvY8bXM59cYS 9xFp/oO1TGNbvtsSuGhsnTZ9hz7sVh7PYEgSIdPekjKHpvuIEKxpfSVuT6quZk2facEf 0r3fCXZE0fmgV0XKEUZiUpbX45829BE+0tQcmhDiJlPMrDoWH8U6L/suKw5+cPVLq5J3 JvM3f+6pZ7sSRNSiaVk3kRiI4utplcaA4Q/gyxsXP02Ly9Glgjge5Fzl+/6DE6eXdJnR wimTOAMn3ljGfH8i2s5y1XZXAE16Ym6B2j4JIsB6bBlchUkF07zc3GgYkWmzQ3s6sneD lWZA== X-Gm-Message-State: AOAM532tFGuAmr1KKnS8MLe97gilOGhvvm2Pa+7sO6L1dhu/ykGLpFZv 3InYwWslpxwYAxJy9aw4djQn+WhdSlYYfw== X-Google-Smtp-Source: ABdhPJxalOpU8zChGEnO77Ep6evfdOoJ9SVFFPPSrUfySAKL0powYTAY8e1j9Q/PS+J1+yQuH+Vj4Q== X-Received: by 2002:a17:906:fc12:b0:711:d2e9:99d9 with SMTP id ov18-20020a170906fc1200b00711d2e999d9mr7221848ejb.734.1654589472136; Tue, 07 Jun 2022 01:11:12 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id g1-20020a170906348100b00702d8b37a03sm7449397ejb.17.2022.06.07.01.11.11 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:11 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 14/23] microblaze: Optimize register usage in relocate_code Date: Tue, 7 Jun 2022 10:10:31 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean There are additional operations which can be done simpler that's why improve logic around relocation address r7 handling and _start symbol. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 2aae4a0b7ccb..f2d6d12deb73 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -271,7 +271,6 @@ relocate_code: mts rshr, r1 addi r31, r6, 0 /* Start to use new GD */ - add r23, r0, r7 /* Move reloc addr to r23 */ /* Relocate text and data - r12 temp value */ addi r21, r0, _start addi r22, r0, _end /* Include BSS too */ @@ -280,15 +279,13 @@ relocate_code: rsub r6, r21, r22 or r5, r0, r0 1: lw r12, r21, r5 /* Load u-boot data */ - sw r12, r23, r5 /* Write zero to loc */ + sw r12, r7, r5 /* Write zero to loc */ cmp r12, r5, r6 /* Check if we have reach the end */ bneid r12, 1b addi r5, r5, 4 /* Increment to next loc - relocate code */ /* R23 points to the base address. */ - add r23, r0, r7 /* Move reloc addr to r23 */ - addi r24, r0, _start /* Get reloc offset */ - rsub r23, r24, r23 /* keep - this is already here gd->reloc_off */ + rsub r23, r21, r7 /* keep - this is already here gd->reloc_off */ /* Setup vectors with post-relocation symbols */ add r5, r0, r23 /* load gd->reloc_off to r5 */ From patchwork Tue Jun 7 08:10:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639854 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ojqoCpK9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNS84zsTz9sFs for ; Tue, 7 Jun 2022 18:14:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E025284301; Tue, 7 Jun 2022 10:12:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="ojqoCpK9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EF48842C2; Tue, 7 Jun 2022 10:11:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ADBE384303 for ; Tue, 7 Jun 2022 10:11:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x62e.google.com with SMTP id me5so33034536ejb.2 for ; Tue, 07 Jun 2022 01:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OZCF85I+HN+19/0fhqCmYYNhX4zBupMcIlkRNf6lnE4=; b=ojqoCpK9A4AIwFKcUuPjfFOHWV+MF7gC0muNrEuxuE0ek2syE+KD5tAS3AfvMHdzo2 NZhcsAfB952k2eMJzZBT+JsBSOmGIpLxB/nMqJbVtoUNaxqD+4cZGJNk/bztAhs8K13v AqfN+iYWIX9iEugay6W7sQsS8iVpmEwa6oBAjk82dfRBTysx0cl4gr+DQM72bcRWC01J ND7AXt8DSGdsSFRYzC+8DIgP0LrcrbrNQ+uBYwpWvnjjitk6Gn9Z+LevB6aZU/l6jG7o xiBhojkWqO6gU9AbXnmA1r8YNIqCXS+1mm9NNbnHm9ASrH6GhSzMKWTK7q0fSE84O7Tg TovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OZCF85I+HN+19/0fhqCmYYNhX4zBupMcIlkRNf6lnE4=; b=iHMUVfMIYwwL67mmEgVDFWWnoHr/1C7tgW9T37rBhJECwsta905VyLEBvwdpimHm1J VXrMJeKcQoPXYVw9YNxXrVzI6EMoQwUkn/2IW1HkQMcxmBE7PRIvlUpAjE4keCDPUVg8 ze760Bn36RFRa7QtWNDR2bW5PQg6GSij/yq6AN8gcdyL/G0mt/nFiK1XRzDInQK7Iz3k ddKawRDVFdc+g6uRcizqJ4isFMPKDEJSf4MK3Y9SaJVakqQgE+dFWF5SAX27xwguGNZJ Vt9CtC8wG81BSa8ArgeBbFh79Gc4tQca35J+m0lyzmeQ2I/GgH4E42zyuLJ8tvz39V6s 948A== X-Gm-Message-State: AOAM530TJCev1e6nAw+ZPhGEGHqvGU61fI2kFWeotGpVBW7ZMH27V8wm SaP391eOAWX7YO81dMrLLESmaqBx1ghlEA== X-Google-Smtp-Source: ABdhPJxC/cZpWKKSlU4i57S1ScXYo56RCbz4fuHh1WycGXXiv9jHcbSgc685fuctkGziT26uRVqyCQ== X-Received: by 2002:a17:907:968e:b0:6f4:d80f:f0c3 with SMTP id hd14-20020a170907968e00b006f4d80ff0c3mr23934368ejc.145.1654589474065; Tue, 07 Jun 2022 01:11:14 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id bk2-20020a170906b0c200b006fef557bb7asm7230311ejb.80.2022.06.07.01.11.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:13 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 15/23] microblaze: Remove code around r20 in relocate_code() Date: Tue, 7 Jun 2022 10:10:32 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean r20 is not used that's why remove logic around it. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index f2d6d12deb73..c3d925c1d151 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -310,11 +310,6 @@ relocate_code: bneid r12, 3b addik r21. r21, 4 - /* Update pointer to GOT */ - mfs r20, rpc - addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8 - addk r20, r20, r23 - /* Flush caches to ensure consistency */ addik r5, r0, 0 addik r6, r0, XILINX_DCACHE_BYTE_SIZE From patchwork Tue Jun 7 08:10:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639856 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=VL8ebDGI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNSg1W53z9sFs for ; Tue, 7 Jun 2022 18:14:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A1C8842A6; Tue, 7 Jun 2022 10:12:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="VL8ebDGI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C66A484328; Tue, 7 Jun 2022 10:12:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8DB1584300 for ; Tue, 7 Jun 2022 10:11:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x632.google.com with SMTP id m20so33505232ejj.10 for ; Tue, 07 Jun 2022 01:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bSXkvyStGAZVgeS0XHp3H5CwwNK450lFFcau+4IwfXI=; b=VL8ebDGIG0vLw9zh2lnJRyZ+Dvfi/ulT17EgbzOehNRJESZHUYvJXpom5GGCrBSay7 mF97A7fYnBLke2TMutY5MRlat72+8e5my1GBhHlNdA4/8+pMrw33dKwg7bYhmDdgcMgt +6Mly5f4yP77XuE98R2O0nGqS2PBQ8/LX5k40E/3xqb9I2ElhxDKi2Y5Eyl/l5TBK6rX 4DNI50PgXM52qlSHg4U7ZBdHsp5wOfur0nRaCdIykTMyZfVhHF+seXRAK7fabRDc9/aj cjY/1PxHUOXYOojzbN4sMjGG+UTkRQ0Gc5nSpc7nN/+PJ4+o/OiOId8ukvc/FxAxcjPv Bq8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bSXkvyStGAZVgeS0XHp3H5CwwNK450lFFcau+4IwfXI=; b=IAD8ZWOwKcWOLPVkNB2Z6hlZI5t6dcjICMLQL3dS/dfeQsywuZDtKlry8PEwDbQI8k 7MT9uXO1GxfKdrrj8xu7ZGBjfSstniaiR6iT5fl8z/8Z+Wo36fUT6YY27BiWWymLttj0 VnlKhvD0yL42NE5H2qCCywbJxMr8jhGEJL5+BTTm75AEbWexCc5cF1haStpIx3Fz4ZnI 3IyWgshu7Je3D3nPX26262pkJWlzOpCCTXQ/rQ65gyAapNO8s8bldLCkZGxhjzsGVhw0 DRX2SH9qd/3eu1ySOz9VQOHUCokgesjOeQadMGcgdaLofBkdEmOstN/eMeB3h5HEWUTI sz0Q== X-Gm-Message-State: AOAM531i8aydmD9UGavxLZ+iw8KYL6ir7tqJnOYIRodQjtMgg3HZYi4Q WFrZSoNm/FaqMRCWVHWtugFGeySfEtN9Yg== X-Google-Smtp-Source: ABdhPJyhaZQMQdns0OyV9DKkLSwRCg/7msXF6cNfTXBZ7jhFOOQzzOo/YGRvp4yd/Lgrghg8tuVE3g== X-Received: by 2002:a17:906:3985:b0:70c:a5fe:d4fb with SMTP id h5-20020a170906398500b0070ca5fed4fbmr22217593eje.127.1654589475989; Tue, 07 Jun 2022 01:11:15 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id y12-20020a170906470c00b00711d0b41bcfsm2083694ejq.0.2022.06.07.01.11.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:15 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 16/23] microblaze: Remove _start symbol handling at U-Boot start Date: Tue, 7 Jun 2022 10:10:33 +0200 Message-Id: <9447984774bf2d9afeb666370fff2e41409a9fa6.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Right now U-Boot runs all the time from the same address where it is loaded but going to full relocation code starting address doesn't need to be fixed and can be simply discovered from reading PC register. That's why use r20 to get PC address and subtract offset from the beginning to get starting address. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index c3d925c1d151..db3998f54505 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -14,15 +14,16 @@ .global _start _start: mts rmsr, r0 /* disable cache */ + mfs r20, rpc + addi r20, r20, -4 mts rslr, r0 - addi r8, r0, _start - mts rshr, r8 + mts rshr, r20 #if defined(CONFIG_SPL_BUILD) addi r1, r0, CONFIG_SPL_STACK_ADDR #else - add r1, r0, r8 + add r1, r0, r20 #endif addi r1, r1, -4 /* Decrement SP to top of memory */ From patchwork Tue Jun 7 08:10:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639855 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=78s12OQU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNSQ4bl6z9sFs for ; Tue, 7 Jun 2022 18:14:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 701E7843AD; Tue, 7 Jun 2022 10:12:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="78s12OQU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51D8F84355; Tue, 7 Jun 2022 10:12:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4784B84328 for ; Tue, 7 Jun 2022 10:11:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52e.google.com with SMTP id 25so21633267edw.8 for ; Tue, 07 Jun 2022 01:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NsVpRAR+tLl3gI80sHbde7LIb8JbGzv25WdycO5eA6E=; b=78s12OQUKW9MFWFNUNGdPdGIevJmoYXwBdpgcvm7gRakQbpElleJ1OB0ksPEwzGejQ wjs/q4bhDZTEvQF3kUdt6E2gspRO6i1/Sxvhwj/3bLBUmTDMTIZBxjl4AJHszK5S5jXg HdXbBxddRQYwGTAlenOzSUEWltz2+eqibmwEAPf31rA/EnNLIkaZ9yk007P1ytHyxHcR DETUjg3qUe6MAu35R0ZHV4OUnTpnkDja5reIEoVWQSgoAGE0WfbC+0FAGoPdud3rKBNm Wt4H/8MxzzEnpxS6s1ke13wtM3W/IHfhMbshCfQYi3PEEkY5LN44i/voezJsVCBRLMzD RgoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NsVpRAR+tLl3gI80sHbde7LIb8JbGzv25WdycO5eA6E=; b=7aAIa72o4/ni0HbNc8t0RQC7PvT/ftPoh9vaIzjzuVBzEqdcKr5rsyFkxi+mD9IOe0 xyRbs+qGdCxx6S3rBcHXW9h87PlJllWGsJI2UXZ2Sf/OLoX6GBJaJJu1SPRgIZyDdZCO g1DWPenrM/wdJzgkRnd5OzK2lgicdcHvvUoh5/Jr9zASEpMr2l52TT3rPaw7EoK+U9hM RltF786Wk7vgMD1DbMH581BFT0GlyHZCiFVyXnKbGsH5gJEmx7rwHL9Yld95z5KB+9H/ lvCk9OD2RI2IUecDds1PJg6uMfdYbxkP+qvztoxObVaBFMVcVmx+IKZ5hl20Bmm5ZIru 99KA== X-Gm-Message-State: AOAM5310nwsln2yWVbD7oYO2NtGaOq4+mXDWqdSVTQrDeaQGyRmsyNL7 kud9I6eXd31N7QC8yOIkk+J/EQUQ2/10QA== X-Google-Smtp-Source: ABdhPJyl9Qx98im7qOgM7KJ1aDp1a08P/vnWXUY/6P8eG+E0DSPjsoXBiZzYN6q0s9+peMFLlgwejA== X-Received: by 2002:a05:6402:5252:b0:42f:b566:c189 with SMTP id t18-20020a056402525200b0042fb566c189mr20054785edd.398.1654589477982; Tue, 07 Jun 2022 01:11:17 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id o22-20020a170906359600b007041e969a8asm7132161ejb.97.2022.06.07.01.11.17 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:17 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 17/23] microblaze: Add comment about reset location Date: Tue, 7 Jun 2022 10:10:34 +0200 Message-Id: <81f84beadbb3549713dba4a1d193b017708eab5c.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Better to add comment to explain why reset vector points all the time to origin U-Boot location. If reset happens U-Boot should start from it's origin location. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index db3998f54505..9aa5fd099361 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -144,6 +144,7 @@ __setup_exceptions: swi r3, r4, 0x4 /* reset address - brai opcode */ addik r6, r0, _start + /* Intentionally keep reset vector back to origin u-boot location */ sw r6, r1, r0 lhu r7, r1, r10 rsubi r8, r10, 0x2 From patchwork Tue Jun 7 08:10:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639864 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=jkvss6R3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNYZ5Hdqz9sFs for ; Tue, 7 Jun 2022 18:19:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D267E8437D; Tue, 7 Jun 2022 10:18:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="jkvss6R3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 19280842E6; Tue, 7 Jun 2022 10:18:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 165F284347 for ; Tue, 7 Jun 2022 10:11:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x62e.google.com with SMTP id me5so33034536ejb.2 for ; Tue, 07 Jun 2022 01:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JXbS7G9526Grfoupw56eMBHxM8MK0IlAgBD0sBbke1Q=; b=jkvss6R3g7ZG+ndgSHleI7DnzpYfrnDp/ytqjcOEfyE6PzSDsfdLPsUJ2Hh0m7ag8p 1OJk6JZ+bFK1ZWN7Ybwql/n8+fMjT/LMfvI+BEgCdMmnnlfzWip9XvJAYLFvsLk4LXzy ouEKU2C1pPr05RKxJXYV+LQ3Kc12Dc8q/FvVU1l2jF47fnXSgkL0aoBut1dxw6qOUKaM LsrE+2LcGwSQaqI/PAi1RxDhxviBw7+HMbQDdbtJpHTM8sHZ8Sx/GT7HJsLs09wjPjJ0 Chn3yhUzMrIq05n5fJLGZV3CoQOK90UGYgEMophTHMS5CZl7oo6qZv+PCam3i3HxUwbC t83Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JXbS7G9526Grfoupw56eMBHxM8MK0IlAgBD0sBbke1Q=; b=4GtGSYbejOLZ7wgdeF8d7sSU4wRONrd3KdAlj4kH/o0Sjp8lkIJlq3z5WCL9b332wi O3hRYp6UJpJHspjIU8BYhvy1TsmaL+IzX8zHltU07eybTJVXG9sBbNNitUQEf5nqxzap 8cICVQtRHrr31So9LR76kJCAr4hColr/XNVlYCeikXICOIfaNqGFhQ7G4Fm9n22g6hG2 wcpECzH+S0vsaNMI5Ptolrf4R/SinsEsXtKOzMHQCboaozD09uPlAXAjZJ9X3k1CRVra atNzGJqW/lYMC0imLCXwIo5vx3ZhUdHO8HWrrzZFw/H1dklZ2mvbr5GHCWY6Far8XpR8 bU3A== X-Gm-Message-State: AOAM531Bi0YoOpzTlKwO4TVERNOnP8KoeWWCg9MHsVo1eZ/gMgnlCvcy 98Far/WwooXgjK54HcSsVi1BEoWlks0tvA== X-Google-Smtp-Source: ABdhPJzFnmY3WeLM21Pp1K6YrQqy0MEeZhikIh7G1XsFE4DaOarlCvz3SFndo1Kr8Xqfq5CBh01Rvg== X-Received: by 2002:a17:906:358a:b0:6f4:2903:417e with SMTP id o10-20020a170906358a00b006f42903417emr25980231ejb.592.1654589479588; Tue, 07 Jun 2022 01:11:19 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id g8-20020a170906198800b00711d5bc20d5sm1548503ejd.221.2022.06.07.01.11.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:19 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v2 18/23] microblaze: Create SYM_ADDR macro to deal with symbols Date: Tue, 7 Jun 2022 10:10:35 +0200 Message-Id: <3a9bd1e82f555c0ab51c45728a2c191ff28aa147.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Symbol handling depends on compilation flags. Right now manual relocation is used that's why symbols can be referenced just by name and there is no need to find them out. But when position independent code (PIC) is used symbols need to be described differently. That's why having one macro change is easier than changing the whole code. Signed-off-by: Michal Simek --- (no changes since v1) arch/microblaze/cpu/start.S | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 9aa5fd099361..72b0f3354731 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -10,6 +10,9 @@ #include #include +#define SYM_ADDR(reg, reg_add, symbol) \ + addi reg, reg_add, symbol + .text .global _start _start: @@ -66,8 +69,8 @@ _start: clear_bss: /* clear BSS segments */ - addi r5, r0, __bss_start - addi r4, r0, __bss_end + SYM_ADDR(r5, r0, __bss_start) + SYM_ADDR(r4, r0, __bss_end) cmp r6, r5, r4 beqi r6, 3f 2: @@ -143,7 +146,7 @@ __setup_exceptions: swi r2, r4, 0x0 /* reset address - imm opcode */ swi r3, r4, 0x4 /* reset address - brai opcode */ - addik r6, r0, _start + SYM_ADDR(r6, r0, _start) /* Intentionally keep reset vector back to origin u-boot location */ sw r6, r1, r0 lhu r7, r1, r10 @@ -157,7 +160,7 @@ __setup_exceptions: swi r2, r4, 0x8 /* user vector exception - imm opcode */ swi r3, r4, 0xC /* user vector exception - brai opcode */ - addik r6, r5, _exception_handler + SYM_ADDR(r6, r5, _exception_handler) sw r6, r1, r0 /* * BIG ENDIAN memory map for user exception @@ -190,7 +193,7 @@ __setup_exceptions: swi r2, r4, 0x10 /* interrupt - imm opcode */ swi r3, r4, 0x14 /* interrupt - brai opcode */ - addik r6, r5, _interrupt_handler + SYM_ADDR(r6, r5, _interrupt_handler) sw r6, r1, r0 lhu r7, r1, r10 rsubi r8, r10, 0x12 @@ -202,7 +205,7 @@ __setup_exceptions: swi r2, r4, 0x20 /* hardware exception - imm opcode */ swi r3, r4, 0x24 /* hardware exception - brai opcode */ - addik r6, r5, _hw_exception_handler + SYM_ADDR(r6, r5, _hw_exception_handler) sw r6, r1, r0 lhu r7, r1, r10 rsubi r8, r10, 0x22 @@ -274,8 +277,8 @@ relocate_code: addi r31, r6, 0 /* Start to use new GD */ /* Relocate text and data - r12 temp value */ - addi r21, r0, _start - addi r22, r0, _end /* Include BSS too */ + SYM_ADDR(r21, r0, _start) + SYM_ADDR(r22, r0, _end) /* Include BSS too */ addi r22, r22, -4 rsub r6, r21, r22 @@ -319,8 +322,8 @@ relocate_code: nop 2: addi r5, r31, 0 /* gd is initialized in board_r.c */ - addi r6, r0, _start - addi r12, r23, board_init_r + SYM_ADDR(r6, r0, _start) + SYM_ADDR(r12, r23, board_init_r) bra r12 /* Jump to relocated code */ .end relocate_code From patchwork Tue Jun 7 08:10:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639862 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=bunQnkzK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNY42sDfz9sFs for ; Tue, 7 Jun 2022 18:18:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 509C6842EF; Tue, 7 Jun 2022 10:18:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="bunQnkzK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E49584300; Tue, 7 Jun 2022 10:18:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12AA98434B for ; Tue, 7 Jun 2022 10:11:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x62e.google.com with SMTP id kq6so20536308ejb.11 for ; Tue, 07 Jun 2022 01:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MJAV2340crnujWnScxaBzMOXZ9TeuKSi0dDXL26pAtQ=; b=bunQnkzKNpKl4LOxyyqwxAD8o7+EZbmo69FdHAfWbsV2drWgqnQ+iUQ/AweRKdNQ97 4zubrjctx/sMJOLf89Jbr47ax6TfK0+mXDejD9HRsDNr+nmSEv3dZE8jzk9/sE97bl9a KR58cA+E8TX3u/etNj4Dz36WyAoSxW43QHSF5rEiIwVfOsVD+EV8ViTfHIDgUpB0qvb7 6Z/JzN8ZWT5e12W9dLOLTV2kEZCETqxWw0K0AwBgRQvl81qr1n0y0VxCWF6EvWH5vkfG v548hN8GrkYrDsW4WrH11vuuXIiKRE88oiwlE9f9Tp2wWcv++Qzcb8rD3xJ/23LGLAi/ I6ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MJAV2340crnujWnScxaBzMOXZ9TeuKSi0dDXL26pAtQ=; b=ypFhoSJQEqNSDo1m4CnYjF0s+EHUMBaZ2Pqf5HOCg4l9DYLG/TB6DsbaIhLNTmawoH xxQemyACcGYUIePxpPUUqQ6dhHunjMiCe9rnZrimkCtzbiulHqr8VQGMSlMBHycvCn6s IldRk3DNRgWvao2VovlGkxa2HF4oA2zA/Bw0Wnhv/1uPTCscU1vcqoTxmwOeG+k/lExV cS8VrasB0xXtIJV+CDWci9wVYIhrQpYHnO9wo7+nO0hjkW3lcXVBYk1weOREgcy6MG9S e3XykxDjVXgrmKAXHn9WgRF5TzbyGqroB5TdrE4yYvdXbWmF6MMoZVvIBLhb+GojOiXs 69Mw== X-Gm-Message-State: AOAM531nbROnF9aCr9HQwljVe3VyROveUkWv3frDPvofni5FSNGBJoDa bBbaCTpSXynz4eOpF6X9G4a+l90qI9AnJQ== X-Google-Smtp-Source: ABdhPJwTDCF47Be/re5IyrB/ntefmOD+tUogbuNOh5C1x0lRzucgQLAbIASbuTZCqQyeoy0ohmC0gg== X-Received: by 2002:a17:906:7309:b0:6f5:ea1:afa with SMTP id di9-20020a170906730900b006f50ea10afamr24830954ejc.170.1654589481568; Tue, 07 Jun 2022 01:11:21 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id kz10-20020a17090777ca00b0070beb9401d9sm6003136ejc.171.2022.06.07.01.11.20 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:20 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 19/23] tools: relocate-rela: Extract elf64 reloc to special function Date: Tue, 7 Jun 2022 10:10:36 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Adding support for new type requires to change code layout that's why move elf64 code to own function for easier maintenance. It also solves the problem with not calling fclose in case of error. Return value from rela_elf64 is saved to variable that's why fclose() is called all the time. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 96 ++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 36065edb3f01..e62247d51e2a 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -216,49 +216,9 @@ static int decode_elf(char **argv) return 1; } -int main(int argc, char **argv) +static int rela_elf64(char **argv, FILE *f) { - FILE *f; - int i, num, ret; - uint64_t file_size; - - if (argc != 3) { - fprintf(stderr, "Statically apply ELF rela relocations\n"); - fprintf(stderr, "Usage: %s \n", - argv[0]); - return 1; - } - - ret = decode_elf(argv); - if (ret) { - fprintf(stderr, "ELF decoding failed\n"); - return ret; - } - - if (rela_start > rela_end || rela_start < text_base) { - fprintf(stderr, "%s: bad rela bounds\n", argv[0]); - return 3; - } - - rela_start -= text_base; - rela_end -= text_base; - - f = fopen(argv[1], "r+b"); - if (!f) { - fprintf(stderr, "%s: Cannot open %s: %s\n", - argv[0], argv[1], strerror(errno)); - return 2; - } - - fseek(f, 0, SEEK_END); - file_size = ftell(f); - rewind(f); - - if (rela_end > file_size) { - // Most likely compiler inserted some section that didn't get - // objcopy-ed into the final binary - rela_end = file_size; - } + int i, num; if ((rela_end - rela_start) % sizeof(Elf64_Rela)) { fprintf(stderr, "%s: rela size isn't a multiple of Elf64_Rela\n", argv[0]); @@ -316,11 +276,61 @@ int main(int argc, char **argv) } } + return 0; +} + +int main(int argc, char **argv) +{ + FILE *f; + int ret; + uint64_t file_size; + + if (argc != 3) { + fprintf(stderr, "Statically apply ELF rela relocations\n"); + fprintf(stderr, "Usage: %s \n", + argv[0]); + return 1; + } + + ret = decode_elf(argv); + if (ret) { + fprintf(stderr, "ELF decoding failed\n"); + return ret; + } + + if (rela_start > rela_end || rela_start < text_base) { + fprintf(stderr, "%s: bad rela bounds\n", argv[0]); + return 3; + } + + rela_start -= text_base; + rela_end -= text_base; + + f = fopen(argv[1], "r+b"); + if (!f) { + fprintf(stderr, "%s: Cannot open %s: %s\n", + argv[0], argv[1], strerror(errno)); + return 2; + } + + fseek(f, 0, SEEK_END); + file_size = ftell(f); + rewind(f); + + if (rela_end > file_size) { + // Most likely compiler inserted some section that didn't get + // objcopy-ed into the final binary + rela_end = file_size; + } + + if (ei_class == 2) + ret = rela_elf64(argv, f); + if (fclose(f) < 0) { fprintf(stderr, "%s: %s: close failed: %s\n", argv[0], argv[1], strerror(errno)); return 4; } - return 0; + return ret; } From patchwork Tue Jun 7 08:10:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639863 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=kKQqp7w2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNYJ5wmfz9sFs for ; Tue, 7 Jun 2022 18:19:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 255E284347; Tue, 7 Jun 2022 10:18:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="kKQqp7w2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E44F3842FC; Tue, 7 Jun 2022 10:18:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE828842E6 for ; Tue, 7 Jun 2022 10:11:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52a.google.com with SMTP id fd25so21927832edb.3 for ; Tue, 07 Jun 2022 01:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SKe1muC2i5OHwRX9wJjkJhAeLwlHXYHd3vsgogxIbGM=; b=kKQqp7w2FhcqGH24Irxo2XRPEIdVXVl4sgALIPBYBWtOR8pavF+efBb7rV8PLJ9D97 MKWh3xeNy0HnVKZ6c7JVdk3qrfVY3mdulrBoDPo/DJ9/oqF8+aMj7oZWU+URuViuNfmx Doj071RFA/TxYO8DwxQdkZrEgmpTUW6SCO5SbkzzFIdU2XXyppBsYFuXJDklDqYrj0jI nHBJRVCaqvFc1eXOlO2ggYdQqr43ykslZpYmrqwGCiuH0WjahhEeYZDRKpXx8RGT4jzl O9nWgqk/oCHnRdb8GYIJI0RZu0MVVg7h/9F1RjWZCCQKs1upryvWZq9Y0VFDK+GDdF3F Tgew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SKe1muC2i5OHwRX9wJjkJhAeLwlHXYHd3vsgogxIbGM=; b=yy7k0AJBUxYouJ16QSROmEqFXDSWyzbxYTSNEXow0fkjCfomMAbUKyRm+9cRclasaC xjg5MfHcDgvtpUUXb/lJyECCZ7jtu8nyn/10UPrcE5r8BgqqVbKrbLMDsOHklzRhx4mz zM0mzUshM/T2cS8Ojhzf8OtES4co2H43+bdTRVz/x9llw49MJQSbBqfOViAnSXhIXVVf I9ksCrRacuRgmobp70EGlNRxlZzd7AtAGX1mAvvGhk6UzOjzP5p90ZKOgzJnpGpCOl6t M/a2dnsTHrr4zVzVK9sbqD9IXJUAEZOSAXcWEMbG0iIhL9WTbEzg3oFaofWtIqW3HKYh xzBg== X-Gm-Message-State: AOAM532oeSGAF2Ti8VYEjTDph9RI9SgLKA4t03qwvT3w5SAT9ObA2IGk kXbwindQDbXck+emHJOpqJC+W25Gv3LE0w== X-Google-Smtp-Source: ABdhPJywzdpDjcnT1gFjwTwF9iW/iMkvTBgAlUTPC6eLKphfiQew4PhuvjZJTSLkpxetyf2q+Omdug== X-Received: by 2002:a05:6402:11d2:b0:42d:e68a:eae0 with SMTP id j18-20020a05640211d200b0042de68aeae0mr31574063edw.111.1654589483193; Tue, 07 Jun 2022 01:11:23 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id f14-20020a170906824e00b006f3ef214debsm7261451ejx.81.2022.06.07.01.11.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:22 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 20/23] tools: relocate-rela: Check that relocation works only for EM_AARCH64 Date: Tue, 7 Jun 2022 10:10:37 +0200 Message-Id: <3a8746ee3ebe349b8237b3c6a85c2bf70fdff6f7.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Relocation support is only for EM_AARCH64 that's why check machine type to make sure that the code will never run on any unsupported one. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index e62247d51e2a..2f7f1796a0ef 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -79,6 +79,11 @@ static int decode_elf64(FILE *felf, char **argv) machine = header.e_machine; debug("Machine\t%d\n", machine); + if (machine != EM_AARCH64) { + fprintf(stderr, "%s: Not supported machine type\n", argv[0]); + return 30; + } + text_base = header.e_entry; section_header_base = header.e_shoff; section_header_size = header.e_shentsize * header.e_shnum; From patchwork Tue Jun 7 08:10:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639860 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=VGJ0r9kq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNXc0MKqz9sFs for ; Tue, 7 Jun 2022 18:18:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE3B284301; Tue, 7 Jun 2022 10:18:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="VGJ0r9kq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C990842FC; Tue, 7 Jun 2022 10:18:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8A68084344 for ; Tue, 7 Jun 2022 10:11:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x635.google.com with SMTP id s12so26354619ejx.3 for ; Tue, 07 Jun 2022 01:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/MXKz3miHLQeUcSvoHpplC9MjJ3HYJSv24t7bHCTUBw=; b=VGJ0r9kq5UJKqpm+2JA4LBylb44jAOn5KZHq8IPfl1W8MNWIkmbrXfOmiI+vZ1WGVb kYag5RKbQaegXFkfamZ8ue7Qe+pIPSCIoBuYm5bQSswkTL0opFo1rluBS2991chO2eC/ PTRKLZudOntsnamtFxSvuqRvqmDJI1D6jAgPbfyWrEN/bGebOfJumIwuBMOXtLljCswc ImCCBd90Pe7VlR1lyEKL957hKLQev7DNK2i/bWZvOex54YDeQXPNvVPGP/OGbPF2Tink VCMd9BINycZXS1ilYi4w/CKCOCUeXqzPXLm/vSV6Fu6GqN+NciBcNXi8XotwDjqOekT7 mGqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/MXKz3miHLQeUcSvoHpplC9MjJ3HYJSv24t7bHCTUBw=; b=fjQTpW81N1HDtOl85KSO3vcomMnI84que/EgEk4moEzbIUlzOO8vSvxVtVi0GNsQHY 7TUY4QhFy6RU4dyb1vZ49QjJINbqofzqWxIPx0EO8Ah2PicU3zBnankCnaUyAGi3PBz3 VoolTRpWb6rpI1jE1DA0DLI9wEa+eIMkFPx53QkINvtb73xfHGWffoyMkAeHxDfI3Rzs 1qLqWfJhEFEkuoGKZwCd0IqtT4eAEBHw7YqYx98zr7UZm8NMHLdWgkA0xDUa/sEhLjD5 HJbRTVpJrUOxj7mK/L2st5H44urwPT6BGeqWnPP4c9os3nhta7XFDvP15lUunvMj7/s1 6CsQ== X-Gm-Message-State: AOAM5307OHmfQ6EJmc5Dx3RfMqDLHCkLXxwPZASmmUXMG+ypA1K4mXqh M6FQ1se2GFSmO4VkA4pXnnWcvRL5ZmCp5Q== X-Google-Smtp-Source: ABdhPJyMWLdZtV6izop9l6Vm4IZVlCfWnPlidcS4MmUxlrIDc0yz3X0HpouOSdbmjhrBz0f1BriUTA== X-Received: by 2002:a17:907:94c3:b0:711:8b08:e7e with SMTP id dn3-20020a17090794c300b007118b080e7emr12183658ejc.451.1654589484769; Tue, 07 Jun 2022 01:11:24 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id v7-20020aa7d647000000b0042bd2012196sm9801457edr.85.2022.06.07.01.11.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:24 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 21/23] tools: relocate-rela: Add support for elf32 decoding Date: Tue, 7 Jun 2022 10:10:38 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add support for 32bit ELF format which is used by Microblaze. Also check that code runs only for Microblaze. Function finds information about rela.dyn and dynsym which will be used later for relocation. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 141 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 2 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 2f7f1796a0ef..7c2a441a8e91 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -22,7 +22,7 @@ static int ei_class; -static uint64_t rela_start, rela_end, text_base; +static uint64_t rela_start, rela_end, text_base, dyn_start; static const bool debug_en; @@ -184,6 +184,142 @@ static int decode_elf64(FILE *felf, char **argv) return 0; } +static int decode_elf32(FILE *felf, char **argv) +{ + size_t size; + Elf32_Ehdr header; + uint64_t section_header_base, section_header_size, sh_offset, sh_size; + Elf32_Shdr *sh_table; /* Elf symbol table */ + int ret, i, machine; + char *sh_str; + + debug("32bit version\n"); + + /* Make sure we are at start */ + rewind(felf); + + size = fread(&header, 1, sizeof(header), felf); + if (size != sizeof(header)) { + fclose(felf); + return 25; + } + + machine = header.e_machine; + debug("Machine %d\n", machine); + + if (machine != EM_MICROBLAZE) { + fprintf(stderr, "%s: Not supported machine type\n", argv[0]); + return 30; + } + + text_base = header.e_entry; + section_header_base = header.e_shoff; + + debug("Section header base %x\n", section_header_base); + + section_header_size = header.e_shentsize * header.e_shnum; + + debug("Section header size %d\n", section_header_size); + + sh_table = malloc(section_header_size); + if (!sh_table) { + fprintf(stderr, "%s: Cannot allocate space for section header\n", + argv[0]); + fclose(felf); + return 26; + } + + ret = fseek(felf, section_header_base, SEEK_SET); + if (ret) { + fprintf(stderr, "%s: Can't set pointer to section header: %x/%lx\n", + argv[0], ret, section_header_base); + free(sh_table); + fclose(felf); + return 26; + } + + size = fread(sh_table, 1, section_header_size, felf); + if (size != section_header_size) { + fprintf(stderr, "%s: Can't read section header: %lx/%lx\n", + argv[0], size, section_header_size); + free(sh_table); + fclose(felf); + return 27; + } + + sh_size = sh_table[header.e_shstrndx].sh_size; + debug("e_shstrndx %x, sh_size %lx\n", header.e_shstrndx, sh_size); + + sh_str = malloc(sh_size); + if (!sh_str) { + fprintf(stderr, "malloc failed\n"); + free(sh_table); + fclose(felf); + return 28; + } + + /* + * Specifies the byte offset from the beginning of the file + * to the first byte in the section. + */ + sh_offset = sh_table[header.e_shstrndx].sh_offset; + + debug("sh_offset %x\n", header.e_shnum); + + ret = fseek(felf, sh_offset, SEEK_SET); + if (ret) { + fprintf(stderr, "Setting up sh_offset failed\n"); + free(sh_str); + free(sh_table); + fclose(felf); + return 29; + } + + size = fread(sh_str, 1, sh_size, felf); + if (size != sh_size) { + fprintf(stderr, "%s: Can't read section: %lx/%lx\n", + argv[0], size, sh_size); + free(sh_str); + free(sh_table); + fclose(felf); + return 30; + } + + for (i = 0; i < header.e_shnum; i++) { + debug("%s\n", sh_str + sh_table[i].sh_name); + if (!strcmp(".rela.dyn", (sh_str + sh_table[i].sh_name))) { + debug("Found section\t\".rela_dyn\"\n"); + debug(" at addr\t0x%08x\n", (unsigned int)sh_table[i].sh_addr); + debug(" at offset\t0x%08x\n", (unsigned int)sh_table[i].sh_offset); + debug(" of size\t0x%08x\n", (unsigned int)sh_table[i].sh_size); + rela_start = sh_table[i].sh_addr; + rela_end = rela_start + sh_table[i].sh_size; + } + if (!strcmp(".dynsym", (sh_str + sh_table[i].sh_name))) { + debug("Found section\t\".dynsym\"\n"); + debug(" at addr\t0x%08x\n", (unsigned int)sh_table[i].sh_addr); + debug(" at offset\t0x%08x\n", (unsigned int)sh_table[i].sh_offset); + debug(" of size\t0x%08x\n", (unsigned int)sh_table[i].sh_size); + dyn_start = sh_table[i].sh_addr; + } + } + + /* Clean up */ + free(sh_str); + free(sh_table); + fclose(felf); + + debug("text_base\t0x%08lx\n", text_base); + debug("rela_start\t0x%08lx\n", rela_start); + debug("rela_end\t0x%08lx\n", rela_end); + debug("dyn_start\t0x%08lx\n", dyn_start); + + if (!rela_start) + return 1; + + return 0; +} + static int decode_elf(char **argv) { FILE *felf; @@ -218,7 +354,7 @@ static int decode_elf(char **argv) if (ei_class == 2) return decode_elf64(felf, argv); - return 1; + return decode_elf32(felf, argv); } static int rela_elf64(char **argv, FILE *f) @@ -310,6 +446,7 @@ int main(int argc, char **argv) rela_start -= text_base; rela_end -= text_base; + dyn_start -= text_base; f = fopen(argv[1], "r+b"); if (!f) { From patchwork Tue Jun 7 08:10:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639861 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=8XHvrww+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNXr5Dkjz9sFs for ; Tue, 7 Jun 2022 18:18:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FA018432C; Tue, 7 Jun 2022 10:18:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="8XHvrww+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D44DC8430F; Tue, 7 Jun 2022 10:18:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4250884352 for ; Tue, 7 Jun 2022 10:11:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x635.google.com with SMTP id fu3so32076058ejc.7 for ; Tue, 07 Jun 2022 01:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y5g26acBqiJ9BZKVo9bhgn0V4rOlfQQ+cDhiFcCzPvI=; b=8XHvrww+aPjCAddSebd8xzyDNuLj2RivkBHGRZyRlkZkMb88Dhk83EH60KMJm3nYBi LQIPVrflki8TEtyLeiMh9xH0+yHjWgp+7gK7z2VOTn1nLNBHpVA1hQckceY30XCM1SzZ tQBsOPV6wp9rrPx0MDAJvbf4q3j5yHubW8yx/tqIfsm9WLx1gWMyaynfkno960meIC9K 25rN6vWbTlLDLXAZ3umu5CbgvhOAJ4EL//r3Bm7WAAjgf7bJxrb2icyUtkX9clrK21Xd 40bI29qQCyMzQ2t1p6VBY71TZXLb/mbRRLbjKN5XDzaThgIEpAximhBhNrIANJ20aUol fp6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y5g26acBqiJ9BZKVo9bhgn0V4rOlfQQ+cDhiFcCzPvI=; b=qT6eyW3pN4il6a4mQWWHllUKTPURWNh3rFhIVjyEKQHdv1DJ4NXK5oYrMrr0MQYzmB Wg9DR6EA+TRxfoVm+mVdGc5Gv3ciNmOt5yZ7idkWYNNR7lG1mrn6xB/QDSZmphTK7Egd /gw+GwrdLw/pCpAQfo2Uk4nLKH7oaN2Smxrc80pNCHW2Iy7GobbTLUduFr/V0I+eBjW9 ghijEfcAd4OnqRJZ4UqbDdHtdhSPugm8Sq2wmjxJkgDri0fxfMvPuncGSHC84AoqAoAe AZowhfzRZHW8Zu7jIdo3l1hzCCcHv0bmTka755eDRCdthF1JkYcq1WV4ivveSwisTgt3 Y7hA== X-Gm-Message-State: AOAM531qh/fHMQmvOAc4GhtaKdSbpedXqM+QoCQn8HeBPDL6+LRuVV7B P0zXNIOTNqmplbFsMM+u6n1wK0ZpN6cung== X-Google-Smtp-Source: ABdhPJwHB4nw1PWYMFJimTH1jY7KKzmFzLkIPesfSPRl1VlulZRk0RjJemf3RFxrW3Daa9SToBJMQA== X-Received: by 2002:a17:907:6ea8:b0:711:3404:440d with SMTP id sh40-20020a1709076ea800b007113404440dmr13181284ejc.764.1654589486679; Tue, 07 Jun 2022 01:11:26 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id o19-20020a1709061b1300b006fed85c1a8fsm7339268ejg.202.2022.06.07.01.11.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:26 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Alistair Delva Subject: [PATCH v2 22/23] tools: relocate-rela: Add support for 32bit Microblaze relocation Date: Tue, 7 Jun 2022 10:10:39 +0200 Message-Id: X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Microblaze is 32bit that's why it is using elf32 format. Relocation code requires to get information about rela and dynsym senctions and also text base which was used for compilation. Code build with -fPIC and linked with -pic generates 4 relocation types. R_MICROBLAZE_NONE is the easiest one which doesn't require any action. R_MICROBLAZE_REL only requires write addend to r_offset address. R_MICROBLAZE_32/R_MICROBLAZE_GLOB_DAT are the most complicated. There is a need to find out symbol value with adding symbol value and write it to address pointed by r_offset. Calculation with addend is also added but only 0 addend values are generated now. Signed-off-by: Michal Simek --- (no changes since v1) tools/relocate-rela.c | 166 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 7c2a441a8e91..090fb1acb20c 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -420,6 +420,170 @@ static int rela_elf64(char **argv, FILE *f) return 0; } +static bool supported_rela32(Elf32_Rela *rela, uint32_t *type) +{ + uint32_t mask = 0xffULL; /* would be different on 32-bit */ + *type = rela->r_info & mask; + + debug("Type:\t"); + + switch (*type) { + case R_MICROBLAZE_32: + debug("R_MICROBLAZE_32\n"); + return true; + case R_MICROBLAZE_GLOB_DAT: + debug("R_MICROBLAZE_GLOB_DAT\n"); + return true; + case R_MICROBLAZE_NONE: + debug("R_MICROBLAZE_NONE - ignoring - do nothing\n"); + return false; + case R_MICROBLAZE_REL: + debug("R_MICROBLAZE_REL\n"); + return true; + default: + fprintf(stderr, "warning: unsupported relocation type %" + PRIu32 " at %" PRIx32 "\n", *type, rela->r_offset); + + return false; + } +} + +static int rela_elf32(char **argv, FILE *f) +{ + int i, num, index; + uint32_t value, type; + + if ((rela_end - rela_start) % sizeof(Elf32_Rela)) { + fprintf(stderr, "%s: rela size isn't a multiple of Elf32_Rela\n", argv[0]); + return 3; + } + + num = (rela_end - rela_start) / sizeof(Elf32_Rela); + + debug("Number of entries: %u\n", num); + + for (i = 0; i < num; i++) { + Elf32_Rela rela, swrela; + Elf32_Sym symbols; + uint32_t pos = rela_start + sizeof(Elf32_Rela) * i; + uint32_t addr, pos_dyn; + + debug("\nPossition:\t%d/0x%x\n", i, pos); + + if (fseek(f, pos, SEEK_SET) < 0) { + fprintf(stderr, "%s: %s: seek to %" PRIx32 + " failed: %s\n", + argv[0], argv[1], pos, strerror(errno)); + } + + if (fread(&rela, sizeof(rela), 1, f) != 1) { + fprintf(stderr, "%s: %s: read rela failed at %" + PRIx32 "\n", + argv[0], argv[1], pos); + return 4; + } + + debug("Rela:\toffset:\t%" PRIx32 " r_info:\t%" + PRIu32 " r_addend:\t%" PRIx32 "\n", + rela.r_offset, rela.r_info, rela.r_addend); + + swrela.r_offset = cpu_to_le32(rela.r_offset); + swrela.r_info = cpu_to_le32(rela.r_info); + swrela.r_addend = cpu_to_le32(rela.r_addend); + + debug("SWRela:\toffset:\t%" PRIx32 " r_info:\t%" + PRIu32 " r_addend:\t%" PRIx32 "\n", + swrela.r_offset, swrela.r_info, swrela.r_addend); + + if (!supported_rela32(&swrela, &type)) + continue; + + if (swrela.r_offset < text_base) { + fprintf(stderr, "%s: %s: bad rela at %" PRIx32 "\n", + argv[0], argv[1], pos); + return 4; + } + + addr = swrela.r_offset - text_base; + + debug("Addr:\t0x%" PRIx32 "\n", addr); + + switch (type) { + case R_MICROBLAZE_REL: + if (fseek(f, addr, SEEK_SET) < 0) { + fprintf(stderr, "%s: %s: seek to %" + PRIx32 " failed: %s\n", + argv[0], argv[1], addr, strerror(errno)); + return 5; + } + + debug("Write addend\n"); + + if (fwrite(&rela.r_addend, sizeof(rela.r_addend), 1, f) != 1) { + fprintf(stderr, "%s: %s: write failed at %" PRIx32 "\n", + argv[0], argv[1], addr); + return 4; + } + break; + case R_MICROBLAZE_32: + case R_MICROBLAZE_GLOB_DAT: + /* global symbols read it and add reloc offset */ + index = swrela.r_info >> 8; + pos_dyn = dyn_start + sizeof(Elf32_Sym) * index; + + debug("Index:\t%d\n", index); + debug("Pos_dyn:\t0x%x\n", pos_dyn); + + if (fseek(f, pos_dyn, SEEK_SET) < 0) { + fprintf(stderr, "%s: %s: seek to %" + PRIx32 " failed: %s\n", + argv[0], argv[1], pos_dyn, strerror(errno)); + return 5; + } + + if (fread(&symbols, sizeof(symbols), 1, f) != 1) { + fprintf(stderr, "%s: %s: read symbols failed at %" + PRIx32 "\n", + argv[0], argv[1], pos_dyn); + return 4; + } + + debug("Symbol description:\n"); + debug(" st_name:\t0x%x\n", symbols.st_name); + debug(" st_value:\t0x%x\n", symbols.st_value); + debug(" st_size:\t0x%x\n", symbols.st_size); + + value = swrela.r_addend + symbols.st_value; + + debug("Value:\t0x%x\n", value); + + if (fseek(f, addr, SEEK_SET) < 0) { + fprintf(stderr, "%s: %s: seek to %" + PRIx32 " failed: %s\n", + argv[0], argv[1], addr, strerror(errno)); + return 5; + } + + if (fwrite(&value, sizeof(rela.r_addend), 1, f) != 1) { + fprintf(stderr, "%s: %s: write failed at %" PRIx32 "\n", + argv[0], argv[1], addr); + return 4; + } + + break; + case R_MICROBLAZE_NONE: + debug("R_MICROBLAZE_NONE - skip\n"); + break; + default: + fprintf(stderr, "warning: unsupported relocation type %" + PRIu32 " at %" PRIx32 "\n", + type, rela.r_offset); + } + } + + return 0; +} + int main(int argc, char **argv) { FILE *f; @@ -467,6 +631,8 @@ int main(int argc, char **argv) if (ei_class == 2) ret = rela_elf64(argv, f); + else + ret = rela_elf32(argv, f); if (fclose(f) < 0) { fprintf(stderr, "%s: %s: close failed: %s\n", From patchwork Tue Jun 7 08:10:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1639857 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=NJDcbMfI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHNSy6Qgjz9sFs for ; Tue, 7 Jun 2022 18:15:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C7039843B5; Tue, 7 Jun 2022 10:13:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="NJDcbMfI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4E1638436A; Tue, 7 Jun 2022 10:12:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C7A68431B for ; Tue, 7 Jun 2022 10:11:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x632.google.com with SMTP id v1so22881798ejg.13 for ; Tue, 07 Jun 2022 01:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2TLup6632lZNscDdnO7e8YQL+N6Jhkxa4MCcy4b+mTs=; b=NJDcbMfInVikXY+7WDd5mmPXOXgr04VFgJHOFNacMNmo6ucy5faeIrW44i3Cz3ONW9 jPIfxU2xF98oIRNOhJzopoCrABXdNklPukGeBKL0Bv7svb+WEd4kqRRlMo/y3nuIxbZY xkuIALXhH6QXNfDsV4RSJpMwfutw+KbeU62nZWq3NxNQIMx5MInn2JJYGG+IlP1QxslI gCXl0KPs0qn09bOMWhkDxiNfoxz0MzeJjPxlAby99cx6qPjnDlrS/K9hvWT5Elhzfcz2 NlEDyPjDwYyE9TygVCHMzwtvH4zuCHcgamj50z6wvEdpgG8IOuzJaAHNLo/dEyhcKwlB UlFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2TLup6632lZNscDdnO7e8YQL+N6Jhkxa4MCcy4b+mTs=; b=Xl8azn4PxtCMTn4M9mamb64kmK02qUmIp/a1LLwxo+i7uwdEoauVxC1RLBjjgrhZYN t0GotRPlrecNgErVlxHQlFvZUgq/+nJKXDLZ6N/BPFzh2Ooy+ko/A9waylnAzOxBEL1i 0fa1nt/Gp3eDgPYnxyvm2GU934QYytM3XvyXdn0Diapoy7xVsBZ3KtLoOiXKuvsuh3ix Rz7PF8gjtTODB/X4kMVGkK5q3+YDN+UAndcRM7pXzC75BXciDBDcJWAUXegeGkpo6yEq AZrizy8GcFRER8/L9I7i876lGcSc9ixSb4BGGArGN/GQapepwVrfh1rkdVvk0EH4korY U3Yw== X-Gm-Message-State: AOAM532Z1NHGf0Aesa7wXA9PybUCix0uXv8WLt2BB9/3p7GYbaqCQUE3 3XLiL29S44vSNVEExrVshKEFsqr4GXxmig== X-Google-Smtp-Source: ABdhPJzAsn1c1CKW6r7pHPhEdxGoUWuBi7eNhiz31lIqy98STCnstqk56veF0nP0pLAM6+Nfq9V+lA== X-Received: by 2002:a17:907:7b86:b0:711:d2c8:ab18 with SMTP id ne6-20020a1709077b8600b00711d2c8ab18mr7020158ejc.580.1654589488386; Tue, 07 Jun 2022 01:11:28 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id ge16-20020a170907909000b00709e786c7b2sm6346401ejb.213.2022.06.07.01.11.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 01:11:27 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Bin Meng , Heinrich Schuchardt , Marek Vasut , Michal Simek , Ovidiu Panait , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v2 23/23] microblaze: Add support for run time relocation Date: Tue, 7 Jun 2022 10:10:40 +0200 Message-Id: <8551642137eb1236da102317afbc399dc38a0542.1654589430.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Microblaze is using NEEDS_MANUAL_RELOC from the beginnging. This is causing issues with function pointer arrays which need to be updated manually after relocation. Building code with -fPIC and linking with -pic will remove this limitation and there is no longer need to run manual update. By default still old option is enabled but by disabling NEEDS_MANUAL_RELOC code will be compiled for full relocation. The patch does couple of things which are connected to each other. - Define STATIC_RELA dependency to call relocate-rela to fill sections. - REMAKE_ELF was already enabled but u-boot file can't be used because sections are empty. relocate-rela will fill them and output file is u-boot.elf which should be used. - Add support for full relocation (u-boot.elf) - Add support for early relocation when u-boot.bin is loaded to different address then CONFIG_SYS_TEXT_BASE - Add rela.dyn and dynsym sections Disabling NEEDS_MANUAL_RELOC U-Boot size increased by 10% of it's original size (550kB to 608kB). Signed-off-by: Michal Simek --- (no changes since v1) arch/Kconfig | 1 - arch/microblaze/Kconfig | 14 +++++ arch/microblaze/config.mk | 5 ++ arch/microblaze/cpu/Makefile | 1 + arch/microblaze/cpu/relocate.c | 111 +++++++++++++++++++++++++++++++++ arch/microblaze/cpu/start.S | 66 ++++++++++++++++++++ arch/microblaze/cpu/u-boot.lds | 14 +++++ common/board_f.c | 2 + 8 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 arch/microblaze/cpu/relocate.c diff --git a/arch/Kconfig b/arch/Kconfig index 02de32f9c77f..6c8d295d66b2 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -76,7 +76,6 @@ config M68K config MICROBLAZE bool "MicroBlaze architecture" - select NEEDS_MANUAL_RELOC select SUPPORT_OF_CONTROL imply CMD_IRQ diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index d7d1b219704e..6f45d19330a1 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -4,6 +4,20 @@ menu "MicroBlaze architecture" config SYS_ARCH default "microblaze" +config NEEDS_MANUAL_RELOC + bool "Disable position-independent pre-relocation code" + default y + help + U-Boot expects to be linked to a specific hard-coded address, and to + be loaded to and run from that address. This option lifts that + restriction, thus allowing the code to be loaded to and executed from + almost any 4K aligned address. This logic relies on the relocation + information that is embedded in the binary to support U-Boot + relocating itself to the top-of-RAM later during execution. + +config STATIC_RELA + def_bool y if !NEEDS_MANUAL_RELOC + choice prompt "Target select" optional diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index 3e84a832fc12..d35b4f6db7a1 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -17,6 +17,11 @@ ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC endif +ifeq ($(CONFIG_STATIC_RELA),y) +PLATFORM_CPPFLAGS += -fPIC +LDFLAGS_u-boot += -pic +endif + ifeq ($(CONFIG_SYS_LITTLE_ENDIAN),y) PLATFORM_ELFFLAGS += -B microblaze $(OBJCOPYFLAGS) -O elf32-microblazeel else diff --git a/arch/microblaze/cpu/Makefile b/arch/microblaze/cpu/Makefile index f7a83d07b6f6..1feffc6a97c0 100644 --- a/arch/microblaze/cpu/Makefile +++ b/arch/microblaze/cpu/Makefile @@ -6,4 +6,5 @@ extra-y = start.o obj-y = irq.o obj-y += interrupts.o cache.o exception.o timer.o +obj-$(CONFIG_STATIC_RELA) += relocate.o obj-$(CONFIG_SPL_BUILD) += spl.o diff --git a/arch/microblaze/cpu/relocate.c b/arch/microblaze/cpu/relocate.c new file mode 100644 index 000000000000..b00d02b1dfcc --- /dev/null +++ b/arch/microblaze/cpu/relocate.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * (C) Copyright 2022 Advanced Micro Devices, Inc + * Michal Simek + */ + +#include +#include + +#define R_MICROBLAZE_NONE 0 +#define R_MICROBLAZE_32 1 +#define R_MICROBLAZE_REL 16 +#define R_MICROBLAZE_GLOB_DAT 18 + +/** + * mb_fix_rela - update relocation to new address + * @reloc_addr: new relocation address + * @verbose: enable version messages + * @rela_start: rela section start + * @rela_end: rela section end + * @dyn_start: dynamic section start + * @origin_addr: address where u-boot starts(doesn't need to be CONFIG_SYS_TEXT_BASE) + */ +void mb_fix_rela(u32 reloc_addr, u32 verbose, u32 rela_start, + u32 rela_end, u32 dyn_start, u32 origin_addr) +{ + u32 num, type, mask, i, reloc_off; + + /* + * Return in case u-boot.elf is used directly. + * Skip it when u-boot.bin is loaded to different address than + * CONFIG_SYS_TEXT_BASE. In this case relocation is necessary to run. + */ + if (reloc_addr == CONFIG_SYS_TEXT_BASE) { + debug_cond(verbose, + "Relocation address is the same - skip relocation\n"); + return; + } + + reloc_off = reloc_addr - origin_addr; + + debug_cond(verbose, "Relocation address:\t0x%08x\n", reloc_addr); + debug_cond(verbose, "Relocation offset:\t0x%08x\n", reloc_off); + debug_cond(verbose, "Origin address:\t0x%08x\n", origin_addr); + debug_cond(verbose, "Rela start:\t0x%08x\n", rela_start); + debug_cond(verbose, "Rela end:\t0x%08x\n", rela_end); + debug_cond(verbose, "Dynsym start:\t0x%08x\n", dyn_start); + + num = (rela_end - rela_start) / sizeof(Elf32_Rela); + + debug_cond(verbose, "Number of entries:\t%u\n", num); + + for (i = 0; i < num; i++) { + Elf32_Rela *rela; + u32 temp; + + rela = (Elf32_Rela *)(rela_start + sizeof(Elf32_Rela) * i); + + mask = 0xffULL; /* would be different on 32-bit */ + type = rela->r_info & mask; + + debug_cond(verbose, "\nRela possition:\t%d/0x%x\n", + i, (u32)rela); + + switch (type) { + case R_MICROBLAZE_REL: + temp = *(u32 *)rela->r_offset; + + debug_cond(verbose, "Type:\tREL\n"); + debug_cond(verbose, "Rela r_offset:\t\t0x%x\n", rela->r_offset); + debug_cond(verbose, "Rela r_info:\t\t0x%x\n", rela->r_info); + debug_cond(verbose, "Rela r_addend:\t\t0x%x\n", rela->r_addend); + debug_cond(verbose, "Value at r_offset:\t0x%x\n", temp); + + rela->r_offset += reloc_off; + rela->r_addend += reloc_off; + + temp = *(u32 *)rela->r_offset; + temp += reloc_off; + *(u32 *)rela->r_offset = temp; + + debug_cond(verbose, "New:Rela r_offset:\t0x%x\n", rela->r_offset); + debug_cond(verbose, "New:Rela r_addend:\t0x%x\n", rela->r_addend); + debug_cond(verbose, "New:Value at r_offset:\t0x%x\n", temp); + break; + case R_MICROBLAZE_32: + case R_MICROBLAZE_GLOB_DAT: + debug_cond(verbose, "Type:\t(32/GLOB) %u\n", type); + debug_cond(verbose, "Rela r_offset:\t\t0x%x\n", rela->r_offset); + debug_cond(verbose, "Rela r_info:\t\t0x%x\n", rela->r_info); + debug_cond(verbose, "Rela r_addend:\t\t0x%x\n", rela->r_addend); + debug_cond(verbose, "Value at r_offset:\t0x%x\n", temp); + + rela->r_offset += reloc_off; + + temp = *(u32 *)rela->r_offset; + temp += reloc_off; + *(u32 *)rela->r_offset = temp; + + debug_cond(verbose, "New:Rela r_offset:\t0x%x\n", rela->r_offset); + debug_cond(verbose, "New:Value at r_offset:\t0x%x\n", temp); + break; + case R_MICROBLAZE_NONE: + debug_cond(verbose, "R_MICROBLAZE_NONE - skip\n"); + break; + default: + debug_cond(verbose, "warning: unsupported relocation type %d at %x\n", + type, rela->r_offset); + } + } +} diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 72b0f3354731..9a661e785f6d 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -10,8 +10,16 @@ #include #include +#if defined(CONFIG_STATIC_RELA) +#define SYM_ADDR(reg, reg_add, symbol) \ + mfs r20, rpc; \ + addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8; \ + lwi reg, r20, symbol@GOT; \ + addk reg, reg reg_add; +#else #define SYM_ADDR(reg, reg_add, symbol) \ addi reg, reg_add, symbol +#endif .text .global _start @@ -27,6 +35,39 @@ _start: addi r1, r0, CONFIG_SPL_STACK_ADDR #else add r1, r0, r20 +#if defined(CONFIG_STATIC_RELA) + bri 1f + + /* Force alignment for easier ASM code below */ +#define ALIGNMENT_ADDR 0x20 + .align 4 +uboot_dyn_start: + .word __rel_dyn_start + +uboot_dyn_end: + .word __rel_dyn_end + +uboot_sym_start: + .word __dyn_sym_start +1: + + addi r5, r20, 0 + add r6, r0, r0 + + lwi r7, r20, ALIGNMENT_ADDR + addi r7, r7, -CONFIG_SYS_TEXT_BASE + add r7, r7, r5 + lwi r8, r20, ALIGNMENT_ADDR + 0x4 + addi r8, r8, -CONFIG_SYS_TEXT_BASE + add r8, r8, r5 + lwi r9, r20, ALIGNMENT_ADDR + 0x8 + addi r9, r9, -CONFIG_SYS_TEXT_BASE + add r9, r9, r5 + addi r10, r0, CONFIG_SYS_TEXT_BASE + + brlid r15, mb_fix_rela + nop +#endif #endif addi r1, r1, -4 /* Decrement SP to top of memory */ @@ -297,6 +338,30 @@ relocate_code: brlid r15, __setup_exceptions nop +#if defined(CONFIG_STATIC_RELA) + /* reloc_offset is current location */ + SYM_ADDR(r10, r0, _start) + + /* r5 new address where I should copy code */ + add r5, r0, r7 /* Move reloc addr to r5 */ + + /* Verbose message */ + addi r6, r0, 0 + + SYM_ADDR(r7, r0, __rel_dyn_start) + rsub r7, r10, r7 + add r7, r7, r5 + SYM_ADDR(r8, r0, __rel_dyn_end) + rsub r8, r10, r8 + add r8, r8, r5 + SYM_ADDR(r9, r0, __dyn_sym_start) + rsub r9, r10, r9 + add r9, r9, r5 + brlid r15, mb_fix_rela + nop + + /* end of code which does relocation */ +#else /* Check if GOT exist */ addik r21, r23, _got_start addik r22, r23, _got_end @@ -314,6 +379,7 @@ relocate_code: cmpu r12, r21, r22 /* Check if this cross boundary */ bneid r12, 3b addik r21. r21, 4 +#endif /* Flush caches to ensure consistency */ addik r5, r0, 0 diff --git a/arch/microblaze/cpu/u-boot.lds b/arch/microblaze/cpu/u-boot.lds index 2b316cc7f5a5..821cc55d7b30 100644 --- a/arch/microblaze/cpu/u-boot.lds +++ b/arch/microblaze/cpu/u-boot.lds @@ -46,6 +46,20 @@ SECTIONS } __init_end = . ; + . = ALIGN(4); + __rel_dyn_start = .; + .rela.dyn : { + *(.rela.dyn) + } + __rel_dyn_end = .; + + . = ALIGN(4); + __dyn_sym_start = .; + .dynsym : { + *(.dynsym) + } + __dyn_sym_end = .; + .bss ALIGN(0x4): { __bss_start = .; diff --git a/common/board_f.c b/common/board_f.c index 51d2f3c365e9..a5666ca77c24 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -684,6 +684,8 @@ static int setup_reloc(void) #ifdef CONFIG_SYS_TEXT_BASE #ifdef ARM gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start; +#elif defined(CONFIG_MICROBLAZE) + gd->reloc_off = gd->relocaddr - (u32)_start; #elif defined(CONFIG_M68K) /* * On all ColdFire arch cpu, monitor code starts always