From patchwork Wed Jun 15 10:03: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: 1643564 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=NiPlqT7T; 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 4LNLW82Rm5z9vF7 for ; Wed, 15 Jun 2022 20:04:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A6C68442B; Wed, 15 Jun 2022 12:04:10 +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="NiPlqT7T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4BB8684451; Wed, 15 Jun 2022 12:04: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-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 7202F8442E for ; Wed, 15 Jun 2022 12:04:05 +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 s12so22189828ejx.3 for ; Wed, 15 Jun 2022 03:04:05 -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=pOtLZs41fHcgECsjEeIPn5fTsem4JqTfqS3y+qxAMRE=; b=NiPlqT7TQqVtCPma1CNxP6knDaO3RZrXKebYezSd7rlZg8Jvr3Hq/OSG5Q8fWhyAyq xjqzyZ9TjjG8AQs1FowqNO+nWY4899lhgIxNoAS+DdZT6aBiiR2aWE8cIU16MgEgudV9 ztr5IA9sU82xOhl0Ryip9SZTpjMliF/dZcLMCjJNwkC6R8lJdtGmRFooPBsODBZzEA3F QiGiVf5gKFzZB5AMwYFda8h6EbPloKAYX8AVLLMbE7m14imyu5uexA9xHAcNFpzn17u1 5zNc+BVCZ5FlBD0RpOeGyFRpS227rDiqaEYQXy6yHnQR+WRGSMKphua5nn+EC1VwTFkl l8dg== 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=pOtLZs41fHcgECsjEeIPn5fTsem4JqTfqS3y+qxAMRE=; b=CWA9ntGJ/I6HOiKPSu+OMVIKaEfIgb4rVLi/ZaMb8HAMWjE6g6rbMaUQPXzCa5pMnY L9nT4R0eGpio7jMmtHv4wRLgSXpWfWLvW2AGh2o5fne3R/8QZInPi3Lgnr1jrXuOduk7 0w14SsB9DtbzTh/lVNtN9tIZ1xyKCLRBlswyPtwafwTGKk7hSvUSWZxiFdXDJkdrECJS k5bOMJp2VYkUtUypdojQ0ML2WEvZH00jA1CghisKgarLLlubKtaErtxelzqzdtV/uUOI kmGIS00F4qlXIvoF449TavX7Tj3XRBiw+rApxUWm691js8edHNYWa+EW4XfeDFicWDIH n6Jw== X-Gm-Message-State: AOAM5328EhKOZqJ+f4CGAE5oydlkGLnzgVKX/w8X7ka/pcplwOTrIoXS mOYXuAJkyeRYAenBwivS+7u+/OAW4SsNgQ== X-Google-Smtp-Source: ABdhPJxsbhgUqQrm5HjEDRwa5y90Q8JMjyS/J/+8v9oEKdb9+6PVkA5dsxYK+gRyNpGSyvrYNtSGmQ== X-Received: by 2002:a17:907:7eaa:b0:6df:e82c:f84 with SMTP id qb42-20020a1709077eaa00b006dfe82c0f84mr8338540ejc.590.1655287444805; Wed, 15 Jun 2022 03:04:04 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id j18-20020a17090643d200b006fe8a4ec62fsm6167695ejn.4.2022.06.15.03.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:04 -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 v3 01/23] tools: relocate-rela: Open binary u-boot file later Date: Wed, 15 Jun 2022 12:03:38 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03: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: 1643565 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=V5hpekIi; 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 4LNLWT5vpRz9vF7 for ; Wed, 15 Jun 2022 20:04:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0472C84470; Wed, 15 Jun 2022 12:04:12 +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="V5hpekIi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECEF384453; Wed, 15 Jun 2022 12:04:09 +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-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 770CC8442B for ; Wed, 15 Jun 2022 12:04: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-x636.google.com with SMTP id kq6so22149656ejb.11 for ; Wed, 15 Jun 2022 03:04: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=Cc/h5k4JLa5Y7L74Gchnelx2N0yPVtqhrRSfj4pz9Gs=; b=V5hpekIiHXAnYmDuJXevgYFfG/3B+Cs/fSitRd+s1VwlBCA7Ju3pCKnV2ziICIr0OE jvtr0Wvt+d+awZER18v++7SJDTlmrtcQDbD2weDCFn5zUiOGVAiiDFep95VfaPbB+vXW H8ytSB5LgmE9a9/pC6bMLWsvvPu13EvcuG+H6Hx9ZKdDFLvQbnHXJbgOzbP2eZx4FThG Ib6t9zeJ/f0F0S66Bul2UqqRQbfC39eq90E10CDGMCHgLGEyVcSYFcGCYJ11NJqOvnV+ LQLtVMY+n2Tcm0oRZUUq1mT72zVS/Q/SLLnv+WnXJR8dzn8hBIwgBiJZkuDak4t6kD+P 0MAg== 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=Cc/h5k4JLa5Y7L74Gchnelx2N0yPVtqhrRSfj4pz9Gs=; b=30ZE4P68kLbGx28zEuZWzm3jj4cwmDaW6UrjlSyI39yJjG2idrCBU5Lrlxjc8aRzK9 B5ULlrsMr1soYbmYJZkxDIrT9dT2hcsy5g7nnXNkln2ZdD9ydIkIocyuA7SHuwKcPUC7 DPUYiSuRk2KfJOAKeabNMUkHGP4v7bg3mrgClOV4/UUxRjSfvTfBSxPwMjDwxHHtGA81 KQ2/6jxtjpd91XRyABTmgKOBefWQ1gvkUinFhV3ZfMFUEpRXZQhlxq2Riqqqxp8zrm+u KbtgJ93tlIpP8LI3tipr2lTNmJ4BEc05+WRmKxAU1J61VSaO6ydJ8La2clk6DQCzp8KW L9Lw== X-Gm-Message-State: AOAM530YIUIvuQr994Q0ltdvHgieG8vz3yxa1QEuo56zJgEbJXQ7+ZKo X2+a86xikayIgih+1pKhhhDlpXnHP9QIpw== X-Google-Smtp-Source: AGRyM1sv2v/fyOFYd6F6dIo61c3dM9nE6jRsHD82slNRuCxoPspmznus7UfFP7wZ46qi3ltEUONo9Q== X-Received: by 2002:a17:907:3e92:b0:711:d26c:f91 with SMTP id hs18-20020a1709073e9200b00711d26c0f91mr8104130ejc.283.1655287446718; Wed, 15 Jun 2022 03:04:06 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id r5-20020a508d85000000b0042aca5edba7sm8873447edh.57.2022.06.15.03.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:06 -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 v3 02/23] Makefile: Fix description for relocate-rela parameters Date: Wed, 15 Jun 2022 12:03:39 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03: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: 1643566 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=oHpW0maJ; 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 4LNLWZ75mzz9vF7 for ; Wed, 15 Jun 2022 20:04:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BFC198447D; Wed, 15 Jun 2022 12:04:15 +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="oHpW0maJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6375E8445C; Wed, 15 Jun 2022 12:04: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-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 30A3F84431 for ; Wed, 15 Jun 2022 12:04: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-ed1-x530.google.com with SMTP id b8so15320129edj.11 for ; Wed, 15 Jun 2022 03:04: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=LZz9nMb41ih3udryM7OAU05cmrC0T5SgjXD/Ysd2FX8=; b=oHpW0maJQUyWUcH69DqMLMfg5UT13r0itIx/p1RzD8hvkHDeMBn8N0cMsDtCK0CY/6 pPHL4zaamQeZdE/J5IfmO0nklYaebUjJv7bD3Geych8gEqZRAmvdqeVAJRo5MWD+5TWm czwL81f8C+p7Hc9+Z83GnuAvxyyyGlu0LomPKKBjQLgiC+QyuFUgnPwXYswyTVoJCdzs Mv+HWAINxHSRZPSUbTnTiWuYBu8UZCIc3y31WO5cKcQv4jCcEX6S8C/ui3qyoyWEGo28 2n4xi62jD/AsEBZzdqLtga9ERxq4ClD41r9AOYyV0IGnu9mXeRQWaarCqj2Y7v6I2sNi TUtA== 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=LZz9nMb41ih3udryM7OAU05cmrC0T5SgjXD/Ysd2FX8=; b=SawwWfsZV/ikAS8hTY1WF8JPuLwakRMhUfC7Bu8mp7L8xFooKiMwWfnvHhUEMKLsF7 DeIy3MjQlaxFybPKCqZA7O4O8l9Oc9LaH0wwe0E0XTbozHMWnvexFXWzG2Yd2ualsMA2 M1o5lYP4jtfKFFxbK5qV/tfHqfzVIHTCkjVkj8mCe1GYV40Cy6La1jeF5UBDwQyfcwG8 q2z8+EMaqKPUKVg77T680biL/+5CBJQCIoTYWRdROwTb8EJsptOglShbIUAzOjl4Ksgu ClCMcByqb6E6JPjjdFfacrTsN8b9KHtFcuNbHipjo9QgvQDvrqUpHFCvhEUaryeZ5yV7 +Z8A== X-Gm-Message-State: AJIora9XCwHpBYR7lofwg/LvaP4jc2AWFYVtC2vTf7Tp8QVBLBcA6Yg/ 3iY+N0OJxRnF751TyAYQQmXDRtDYOHXcWA== X-Google-Smtp-Source: AGRyM1ukd6RRNvhHSNXuAY7fAmojhVgQGbxeBbs3Hoaiso2TTdnnXZliYKYo2dN8H8MfvQ3brX9HrQ== X-Received: by 2002:a05:6402:5252:b0:42f:b566:c189 with SMTP id t18-20020a056402525200b0042fb566c189mr11485416edd.398.1655287448620; Wed, 15 Jun 2022 03:04:08 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id b11-20020a056402350b00b0042de8155fa1sm9373535edd.0.2022.06.15.03.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:07 -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 v3 03/23] tools: relocate-rela: Use global variables Date: Wed, 15 Jun 2022 12:03:40 +0200 Message-Id: <665967054a5af6d3c673aeaa51ec629986a1a974.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643567 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=5WrNM2Dm; 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 4LNLWp1rMSz9vF7 for ; Wed, 15 Jun 2022 20:04:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 265A78447E; Wed, 15 Jun 2022 12:04:20 +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="5WrNM2Dm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1205484477; Wed, 15 Jun 2022 12:04:14 +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-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 04EC784453 for ; Wed, 15 Jun 2022 12:04: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-x52f.google.com with SMTP id x62so15346817ede.10 for ; Wed, 15 Jun 2022 03:04: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=fIcTjyMNFWtRElxGIZINXZZescCo1NPOEXdWtrBq004=; b=5WrNM2Dm8GgNs/UWtvRkUVNbb8DighZea6jvn0lNHlSBL0WBpN/x31L69w49SN8wS2 HRKI+0Zy+IVNR/8cjy35xAX3q8vI7I1QaX7Dz0gKP3NO0AA2OB8aqpLrrFdJQCqs7X74 q36h7uQBBUzwWVnzJE0npkM1x3xNvj6zlo6KW6JOq+0DgP4yDjL1giKLH0Y+ju4pjpAW td8nvaPmI9socnO6Q/R3d51n9Hdmz/a6d0sRCPF03moC3lvCiWisaHntYHYyJh+5uZWD rClUX7yGY6+G5vJlnVsRP+gZRtonzEkZKogtHhp0ASQM3M4LnStG8Mz47oBFhgxCvv/J rUxQ== 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=fIcTjyMNFWtRElxGIZINXZZescCo1NPOEXdWtrBq004=; b=5qNgjwd7oS4Y67A6RFA+k5MGChpmwOoala6k3NNjD3hDMio4oE3M6c3wDNbNPM/5MF z/6ziumX1qtycbaqc3Q+YPKfmequbZ6cTygOd95M1sFkhQ7wAY2twS22+pgFSH54kqX+ WoidfifRm8lPso7duPuFOsO7KNp5Lymuv5G3Du2XgqzL1QRof0QLZuC3PBfaiXeRShIC wBYsaaCn5gpm3zvq33lg2FKZt5I2KGzIliEp1aRM5nUVb19EB194ZOuI3MdQ9A/geF8h k57eecswO72yn4l2xvyJYBuUafZgJ/PHKgj6A81TSo1j4oAfdOSiVHpAwIiDmNGa+6PI Bdcg== X-Gm-Message-State: AJIora+HrkSVgBj18d/DikpjSZ9ZdBSiyHNTPib+4/TO6mgc0AOYeeGi 5YIvoGVISUmICBUH/FSgIAWr0HaYeYgsPw== X-Google-Smtp-Source: AGRyM1v9imKvcbjXqtF7oDnRKfUc24bBQ+SDZVxcINDikWSaf5+1EjHGnpCfKCb/GRZb0kRQHqiG4Q== X-Received: by 2002:a05:6402:1e95:b0:42a:c466:52ad with SMTP id f21-20020a0564021e9500b0042ac46652admr11785417edf.340.1655287450212; Wed, 15 Jun 2022 03:04:10 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id x13-20020a170906804d00b006fef557bb7asm6166337ejw.80.2022.06.15.03.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:09 -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 v3 04/23] tools: relocate-rela: Read rela start/end directly from ELF Date: Wed, 15 Jun 2022 12:03:41 +0200 Message-Id: <6136de36cae9aba8db9a92080134915ef9d357c7.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643568 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=uxGPPxfL; 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 4LNLX218Jqz9t6h for ; Wed, 15 Jun 2022 20:05:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E1E684498; Wed, 15 Jun 2022 12:04:22 +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="uxGPPxfL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A8648447A; Wed, 15 Jun 2022 12:04: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-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 BFD3584461 for ; Wed, 15 Jun 2022 12:04:12 +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-x634.google.com with SMTP id me5so22216588ejb.2 for ; Wed, 15 Jun 2022 03:04:12 -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=XPoATS79+BDUUn1rLMxwVV0t+YarA9Ra8Hso0A2xzrw=; b=uxGPPxfLM9enFjDheqG350/taUv03N2dHKWJOdGvnCP9ov072sfZRdlmgPKy8runUV 9xk5R9EfUykFTxMyW0hJTkkOHRKQ9O04pwxlyL4b92WBiCGCtceOaMXWneH2TVKcug+7 /4NsQfj7sV4CErWLhwcoVrq4E/P7rwKq28R1Wf6KHTGt1ryjXq6IUM1pQcZmuLoC1MDB BB7rmKoJq0513z7xfhIEI5tD4pT3y73Fr0NCVwRTnBfXmRlSKmfz3cosArR3YDeK8aV9 A5rBiGmhSsW1dXmdiVBoJ+tpA0KuwkJD/fw6XdgPB1Mju8VEDohxkG+HHy8jXHaW7Gyi 4HHQ== 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=XPoATS79+BDUUn1rLMxwVV0t+YarA9Ra8Hso0A2xzrw=; b=JsARW86VfXuDRKcomL2roSiwGHfWm72BQrQnHOqQW/7ZdGR/ph9EbfR8wyGDEbEifg d78NMwhXqn0YUtRbkpj9XRPHZHK/1dz3xdBVN7++rqIEDBFgOoAd11ffapbSIfjPUE8g eUwim0CPw4hQNcFC1lbOjBjQJOuEosZ23TAQl4O6CQHiHusK0vXHMFFfRi4LmQogxmIU fnK3f5A6mCdWV8AyWXmZyVNhAtqBl9Yt7ngBRyQbuZDPPfpe5lVjixEPGwFuhIH+ONuH bo302T/VAlJGfzEhGMl6UBxuHRpVseUxvfHEZODsqgOjb4H+GlV7Ko89Q1r7+5U2lKbI n3rQ== X-Gm-Message-State: AOAM5339YOnLAxUWzNOs4T224ula2YK9Me91iglWjpVIansdr7uevDnG SzYDfNE4J0N0YAlStfaPy4+POCOiXNsaPQ== X-Google-Smtp-Source: ABdhPJw2YjOv6C3iGELTudaaHa7UKx7O0+7OTJLQ5hSl3js4ZTzDSp9FDM50gj7tn4gD0pxxeAsyNw== X-Received: by 2002:a17:906:51d5:b0:711:f4c7:5085 with SMTP id v21-20020a17090651d500b00711f4c75085mr8514328ejk.650.1655287452023; Wed, 15 Jun 2022 03:04:12 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id w11-20020a170906384b00b007104b37aab7sm6067101ejc.106.2022.06.15.03.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04: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 v3 05/23] microblaze: Switch absolute branches to relative Date: Wed, 15 Jun 2022 12:03:42 +0200 Message-Id: <96443877ae8a5fd78286c8e109979586205f6954.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643569 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=Rzx6w7fe; 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 4LNLXG0PGYz9t6h for ; Wed, 15 Jun 2022 20:05:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1BBE18448B; Wed, 15 Jun 2022 12:04: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="Rzx6w7fe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 657BB84453; Wed, 15 Jun 2022 12:04:19 +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 7639F84459 for ; Wed, 15 Jun 2022 12:04:14 +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 m20so22129664ejj.10 for ; Wed, 15 Jun 2022 03:04:14 -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=1PSFw/GXIunUH9AyDLtTr1daRQcTtBjiK6dcDxt5n/M=; b=Rzx6w7fe+qERaKw49S574JVXfpzstoqK4/vf5geXc07ffk6B3oYgqzyUAYPn6wYZaH xLrkI7oUQ6zXqd0dTEBw6Icklam/+EJRYBV6O6ex6AH7r7BCzhgwfGcAGifV85LQvhtm YnQKbETjBm1nUm2v1Pfx5KkObLtA7pqGvZP7bWxFKkMHqIOdtdPKxJafFpIg/0hCqHqf 7R/hWTkg8J1k1MO2xBeCbLM4eZCh60VLX3HhSurwKuJU05vnRYZ0UQspkOQ+PQHfwRwT loUMIaS4IeRbI9myFz9oJ/UZyXXEMp0GQY6sa4xrh0gYSBLy6bVIRStp5x6s1Ln255mg zIJA== 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=1PSFw/GXIunUH9AyDLtTr1daRQcTtBjiK6dcDxt5n/M=; b=VCYZH5JEDm+te1HR/ecInhphrtbS5rL8QW9zUjXpgNagUo0rCyTI2+fmMNpmOZDuBo ZDvKLHRi4qrPZYxMoLgeRG0YVX7u2nXHUBTz+nUihpMF3umT/v9XURbvcTaxcLO1bhNS sMFknBTLFKNgaNk6fmvfInFnso50gw249EZRuW//vgrQXjgJxh667ftQ8q+qGmWHwZvK TTzQWuTGDeKBfLrvWQvdGxR2x+GYbBs9Jkqrh4eqweZ/0Sojm9sF1UrTaXJTaEF6H+Q7 ywh4HY1/IkEHs8fp5WRfqTffXz7yuvR4BgQ6l2MSETGjn6sQgMcjBk5Da7xcGSTC1Bzw 8TVA== X-Gm-Message-State: AJIora+My7FHyHCV+f3TYXkYGu3jeXV3wHQkq+uCWmbKkPiyqXx2YkII dcPt59+dwdjbaw5MUffq0VDhq8mf0PjigA== X-Google-Smtp-Source: AGRyM1vJh90pJEuYaPjBPm6M2yVAYT0VMVvHzgs4lx/nZaR25Tl36X1ddA6EkIZHZ0Jx+2sMEEWRsA== X-Received: by 2002:a17:906:2001:b0:6f3:bd7f:d878 with SMTP id 1-20020a170906200100b006f3bd7fd878mr8282134ejo.133.1655287453700; Wed, 15 Jun 2022 03:04:13 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id o11-20020a056402438b00b0042dc9aafbfbsm9243679edc.39.2022.06.15.03.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04: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 v3 06/23] microblaze: Fix stack protection behavior Date: Wed, 15 Jun 2022 12:03:43 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643571 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=uajagQv5; 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 4LNLXT0Lv0z9t6h for ; Wed, 15 Jun 2022 20:05:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E85084466; Wed, 15 Jun 2022 12:04:27 +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="uajagQv5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D4DC984486; Wed, 15 Jun 2022 12:04:19 +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 E2F038447E for ; Wed, 15 Jun 2022 12:04:15 +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 s12so22189828ejx.3 for ; Wed, 15 Jun 2022 03:04:15 -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=sHV87L8jXqk1shojKH0Ccz07k3au65rkzfIVZt/PeJ0=; b=uajagQv5RXTU7NcdZQHNnqN/MS9pgy2pfj+8vc9dU1G4H+0j9NmrcjS5HBNGakGv12 WCGsntwHvgN0qs023WgMYPb2Gg9kwrn8Bn/3P43ZH8mFd8PG7ezbyGP/ykp83KirTydV GpQZe1VmnISny8/Y11un94loFNSoiBu/CJE5eGgxF39CuCOcT+fEL8f8LpOxzUDw4YLk ZLebGbbjcE++s8fU1txkQyaaKAWfatWqfhN7MemNsq7ngdx7f5dwTYt9ds6fCJ58t+jM 0G4i+rqCgAbEm7ix76UuxMq3xRyk9oWlxgEmy1ia+eOmrAhvUExJSGfGUa7PLX5iZkv/ o79w== 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=sHV87L8jXqk1shojKH0Ccz07k3au65rkzfIVZt/PeJ0=; b=1f1kKvG3Mp3DIQmijhxJrPsDcJSJeDS9PVoUNKuQZExjRE2Vjwjn//JLK1JOzw99kD /VRGlV4AlK1J4Ul7CLijddUYaUanu7041gXhfKoUIk1ifAVCyyQAw9fuhkCwnXzQ1R4T fhtcxwRgX26SomZ7FEG0qPOLvhxBlf1JMWc7YD4z2OPWJrOcKkF9VS4YQnd0MQrguxgz E4LwEZcndcrEPR05tnLwqPzOHpVKQVFev7mR7LY+ib+Or1Dg10A73uSWEkS+uQhVcvm5 gmEoXMr2qLlY21cNfI5XUrvCTLFp8FXJWijDfoBpp+vYxoRKvx7a+/Sp49SBvfvW2y/f cvpA== X-Gm-Message-State: AOAM532gYAw/ObqRRx1Qjlak3mVCrRV9suozrspslghI7brfovct8PCq ME6F5WaE/N+7tV/rfwW46tVoO7ypIyfx1Q== X-Google-Smtp-Source: AGRyM1uwzIcEourQr8D1LFrzmu37TVmfd9jo3jKYpvGShBa5KVL8eT1EAHJ28nkMzcr+klhq6ZR7VA== X-Received: by 2002:a17:906:b15:b0:715:bf2e:df92 with SMTP id u21-20020a1709060b1500b00715bf2edf92mr7951343ejg.576.1655287455439; Wed, 15 Jun 2022 03:04:15 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id ss19-20020a170907039300b006febde6d771sm6074647ejb.160.2022.06.15.03.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:14 -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 v3 07/23] microblaze: Fix early stack allocation Date: Wed, 15 Jun 2022 12:03:44 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643572 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=6xlZjWD/; 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 4LNLXg1vpQz9t6h for ; Wed, 15 Jun 2022 20:05:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 991908448F; Wed, 15 Jun 2022 12:04:29 +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="6xlZjWD/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10DEC84489; Wed, 15 Jun 2022 12:04:21 +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-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 C723084481 for ; Wed, 15 Jun 2022 12:04:17 +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-x62f.google.com with SMTP id o7so22187177eja.1 for ; Wed, 15 Jun 2022 03:04:17 -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=RHRnHBraUTYxVgQO6N6wdoEAUEjdiTUD5h35kL+Taf0=; b=6xlZjWD/7licyzPtt2Jc2l+4GCl1TgreltMcG7MaSiklytGQyaoSUtXYWc9ZIqMOtU xEJvOLn6CWPGfKjeJ44e1BqJfJSL2786zQgdw8QBVsuP6vXMY9RuR46RPJySeqEY56uZ bvji5u5k0ISwY3pT3sxS8ucJ7ceXC8ei0nAmLCI1mYLXAVBzEMmn5v1DiuRELINfnrk6 +SX/nMfByJmNrEXYI17OmQJVHS0B5MYPn7Nw3b9Vx7PqA0L1UMVOlQ8x16lNDYeslWun AAMeZPFehQHpGa3O4uZga/vhDMh+1Ue6rNBCUTc7cjU7OHHkPWsbBkwognMaUFC1Pmo3 uOZw== 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=RHRnHBraUTYxVgQO6N6wdoEAUEjdiTUD5h35kL+Taf0=; b=TgNUgXYJupe9bkCzEjt0u+5aSeEllTK9vh2K1Xv4q7Bvhi+nuGltikfFp9bYESOArl Tg8XbuvlaKCsuo2JMAQT+ZL8N3i6SidKMRZAVPaojfxELM8LD+n11e6q8BCSU1R7Pss8 4IMgZIdVWw2YfjDm1ZqeD5WJuB4Sb9eGKx4zuA4Fp9JOpqw+gcJbK+a7oLd8SVRl5Op2 0GF/ibY/7Z3KiIASAwZNnRpijYzmNFh7GfB0ooK9+WXdMKoIAwUjbEMZkprlPQegqzi+ DmPj3PAZuSH72+ehI5ZgpXzV4dl36bw3Ce+LZChRaKIYLHC9zn88ldy0R1mdPIHtFl/l sLOg== X-Gm-Message-State: AOAM532QlVd/lNermzGb3AgzlI0t3HHNnYorjOjwAb8bQ+YrLs0WuzMe P+41j+RSm53DA0HXmYToq6fq2zlqGNn4Dw== X-Google-Smtp-Source: ABdhPJw5EnVVLsdAl7bcLQ5q+ZBFKLbj8Bqn38KFP4UimQGdheLMycHurFoK7UlRrC3MVSc4sO38RA== X-Received: by 2002:a17:906:7254:b0:6fe:5637:cbe6 with SMTP id n20-20020a170906725400b006fe5637cbe6mr8040926ejk.612.1655287457114; Wed, 15 Jun 2022 03:04:17 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id pv17-20020a170907209100b00704757b1debsm6092981ejb.9.2022.06.15.03.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:16 -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 v3 08/23] microblaze: Remove CONFIG_TEXT_BASE from code Date: Wed, 15 Jun 2022 12:03:45 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643573 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=fUjOkvbs; 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 4LNLXs2dtVz9t6h for ; Wed, 15 Jun 2022 20:05:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22A76844B5; Wed, 15 Jun 2022 12:04:32 +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="fUjOkvbs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA66C84492; Wed, 15 Jun 2022 12:04:21 +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 9054684478 for ; Wed, 15 Jun 2022 12:04: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-x530.google.com with SMTP id b8so15320129edj.11 for ; Wed, 15 Jun 2022 03:04: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=h0Y6nVy6SmrooEd4XUptFakToyfSRNbptRYo9zrJyPQ=; b=fUjOkvbsttd223Pfz7WOiEIl3thRiXaQH4Zi53IO9AYhCzIlgzubsRJxkrMRedCCb0 GgSRKEYxgbWPLHfhbKKJXsqbU5/vL62wFqFW+24PiB7QNSDuAA0W12XEh8CF9JRltdr7 zfkBPFOxquBBvs85u+7RSIzIceoiXU4MtzvkuDFYP4bNOEp3Pfio5hp1YG4pTSqNq6Po CQQE2f9TaGgv+0JfDz7M5DQRqB9c9b/KVoasdf7SZKm9H5m1j2Zpp+kp52/fLfqKlzRr zuZrr1DssyH90yw+BcEF/Z6JyhhAd4qldlCc4z7AGqgE9xczrt3ZoSCVOu80zv4gDxuJ OHRw== 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=h0Y6nVy6SmrooEd4XUptFakToyfSRNbptRYo9zrJyPQ=; b=1R3IoeQzo/oZJl5/YnOovo/ctuNqPB6DNv2O53UmTxR9rrO5e/TOvypJSTbBjBnceB W0iPL4G9KSEP2+Npby/E6R+QjxnzSc5rnLDYBKY1m7m7qUbSRFHSE4r07l0Ajn5iyhWl J+OojXulGkx+LzR++2bzfnzNi8KRDynk4fz+49J1YvXn3ax0SN6wxxIuMajVIcUx4HNz bf6CiUE3RXbOHCX2CNqohPnCZNepQqK2GIO6nH5aCd0DhXQzh4yC5YOBBlytb2IGOovt u58yuqyOkzOtHeK2D2s29wBLkOGcGKVsAPr3GcYI/DCgUYVpdJW5NcdIQRGXBhjOEJtS rLgQ== X-Gm-Message-State: AJIora8NCWPiYf48CnBsx6STHNQ/+HTzhej0V2lpPyYYzUqEJBYskEEe iVP4GhHeQ78GkBc8rgW+d35sdzIytyImhg== X-Google-Smtp-Source: AGRyM1sLt0OOL3QWCDinHG+fqd/JYpoAH3uicS/vXcAmY02WYWrDL0JD+CP7nryjdHIXRXh6s7v4/A== X-Received: by 2002:aa7:d058:0:b0:42d:f33f:ad21 with SMTP id n24-20020aa7d058000000b0042df33fad21mr11564873edo.388.1655287459111; Wed, 15 Jun 2022 03:04:19 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id p8-20020a056402500800b0042dc0181307sm8859214eda.93.2022.06.15.03.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:18 -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 v3 09/23] microblaze: Fix typo in exception.c Date: Wed, 15 Jun 2022 12:03:46 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643574 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=w0AH66Zi; 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 4LNLY62mktz9t6h for ; Wed, 15 Jun 2022 20:06:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A330F844BD; Wed, 15 Jun 2022 12:04: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="w0AH66Zi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 49F998449C; Wed, 15 Jun 2022 12:04:24 +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-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 532778446C for ; Wed, 15 Jun 2022 12:04:21 +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-x62f.google.com with SMTP id o7so22187177eja.1 for ; Wed, 15 Jun 2022 03:04:21 -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=G2FeJlq5N0uE3t2sB6sFyMtlw3dXTmul2a6GDZHDuVw=; b=w0AH66Zi6/6iHM5j2/v65dEy39ukm3s4R6kwmmgqz7ND/183LWN5XciQzTYs0M9GF4 iwpju5AVkCeURklqIZCeYGMt3b/W7fcGDjfiPmDhGUJwXRPqAL3rbuP0xIn+Se+CLKdB M12U7ZP0DuQpz91mRG6dIJ3LXa7559NVC9KxqrPGWoJX0m974a6jiYR7te9OIXaBGvnw hNDbPR+wQkEvIidtDnMHoSKUmPL3gF8Q5fkdVpzgEVKhuUesOaEOpny7DWmpQpe5YC1l XQTeYFRe7o9OG0ctzfOx5qCynYHWgLi861TtEfpwuPcde9QYJiORRRdPGxS5dVdz8vpt sOVw== 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=G2FeJlq5N0uE3t2sB6sFyMtlw3dXTmul2a6GDZHDuVw=; b=Ea4k3jvByrm9CGESyGKj+8/poqwog1RcMuHWOOY3Mg+AxdNtOhZyM8feFh7K5dgzj+ yZ4+2nPy+978sT+dnnGnJRG3l++qBAFjAywOsjb16rDbSakK9ywaPiS9s4qs6qhqk/yl bMlwF1AHX1A2/e5iY6WX1qTdrd8oCZDiK59XXLDxTKzfi/2n8YbQylEY89cNC/AEyYEl ssSQuaE2CFfulpcAFsfNy3wH+LUXsl5/WxoN0x06M3NDwXmBTVifek5x/QyWAj98L1/E P+oSlP20yfyae2gw6rc6Mah7ZmkpT05KwSNVbrTCLSi4B7z+ASSxjaYk3Ozu+mlW5tqw fouQ== X-Gm-Message-State: AJIora/FD2oB84JYAIKCR4KvChW+1/c1RnQM16nVugi8wwagDx24rTbA 6V2E6Ghednu9VXvkYvkBGNytj0U7ho5bdg== X-Google-Smtp-Source: ABdhPJyYcqmpreXQcfmN4rm+b5rQmmsXL6n20cSmNozteJ7A44n1pwNmF5HKImNvw9sXgPNboXUlUw== X-Received: by 2002:a17:907:6d19:b0:70c:e94c:6ddc with SMTP id sa25-20020a1709076d1900b0070ce94c6ddcmr8162344ejc.730.1655287460803; Wed, 15 Jun 2022 03:04:20 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id u16-20020a17090626d000b0070fd7da3e47sm6085882ejc.127.2022.06.15.03.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:20 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Angelo Dureghello , Daniel Schwierzeck , Huan Wang , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v3 10/23] mips: Move endianness selection to arch/Kconfig Date: Wed, 15 Jun 2022 12:03:47 +0200 Message-Id: <5f5959e1a17a77fe3630aaf6a7a831b81c3738d8.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 v3: - Move NEEDS_MANUAL_RELOC to m68k Kconfig to avoid Kconfig issues Changes in v2: - new patch in series to solve Kconfig warning arch/Kconfig | 25 ++++++++++++++++++++++--- arch/m68k/Kconfig | 3 +++ arch/mips/Kconfig | 18 ------------------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 12de8a11650d..53a7c2a48da0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -8,9 +8,6 @@ config CREATE_ARCH_SYMLINK config HAVE_ARCH_IOREMAP bool -config NEEDS_MANUAL_RELOC - bool - config SYS_CACHE_SHIFT_4 bool @@ -447,3 +444,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/m68k/Kconfig b/arch/m68k/Kconfig index 7f6e4310f1f4..d501c4c97990 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -4,6 +4,9 @@ menu "M68000 architecture" config SYS_ARCH default "m68k" +config NEEDS_MANUAL_RELOC + def_bool y + # processor family config MCF520x select OF_CONTROL 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 Wed Jun 15 10:03:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643575 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=GD87XuDZ; 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 4LNLYF68yZz9t6h for ; Wed, 15 Jun 2022 20:06:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B29FB844AA; Wed, 15 Jun 2022 12:04:36 +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="GD87XuDZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BC6D7844A1; Wed, 15 Jun 2022 12:04:25 +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 56B3984467 for ; Wed, 15 Jun 2022 12:04:23 +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 w27so15350407edl.7 for ; Wed, 15 Jun 2022 03:04:23 -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=Zt7wP/CvOxaAsix7nJNGykoGnfpjanHccbmwcFe+j3g=; b=GD87XuDZoGc3SSD86pnH88c7ldBzOYIve+Goi86OzyCS2v/2sQesFpQKxpwH9TlKew UpoMu09UGCgvvvVIW3POsM4bTptlt+sDiVex0ulBuYpFTq1/AKRtSITCQU5iGqVui/gA H7GMhN2HrhHieqSgKFYwer1D7NoZ24jRv80hzl1P8Uexv62WSbB9G8UuND0j80V9r6wB Kur1HEvC9X2do+7mgClzlbGggC3rT5SxeL/1ZfRJXrDgdZpLoyllNmpjyHdIuZAuRRtV 4kh2zdjVlOeh3zjW00N7i9Q+HPGDZlOP4PVxew8p7Gn9kvMA3+C7UZ3bIpONtUyEU9T9 dL3g== 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=Zt7wP/CvOxaAsix7nJNGykoGnfpjanHccbmwcFe+j3g=; b=iTcqiSLWVHIhGkgOdNkt9Dm/4g/czAoaiiSumhfsVRlQQoSZFbwvZTC3MVqYz+pnaH LmrEJMFtvNtZcjZuq/qTxFtF+eszoJZ2toUhqBIbiAtE7/NiH6SM+cYWW2qsVotDynPL 37jORHZ4brm2q0AEXm88Gy2uxXeRMEU4gI8+ExOoEgJkXUrdMYKVYemaV74UdJSJ1tfz pCKCnQJgq9BK2W3AijugClKDkMymN2+sXuyevD82uP/qToXaVar5wxe8msGozYtmiG70 IGPrh6Vu9USorBabkHHidCg+XritfQFUiay4dOov5C2XhObjTIQQXmhx2yl2QYk1wiQL CJ2g== X-Gm-Message-State: AOAM533dYw+92pmVBaNxKG84D2xYIIg+Jw5LeqRiHdqd2xMknRhQOUFC +MW6ExDEJAi18/XFZj65SuCZc2hDvnbs5A== X-Google-Smtp-Source: ABdhPJyL1l/hOkw050TWg3YEFBHdj4c3XbMy2RldRH2Uy/vrN+cGPFuJ5o+8VfwiBNGoOmBV8qJwBA== X-Received: by 2002:a05:6402:518d:b0:431:5487:9606 with SMTP id q13-20020a056402518d00b0043154879606mr11852872edd.177.1655287462603; Wed, 15 Jun 2022 03:04:22 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id p8-20020a056402500800b0042dc0181307sm8859331eda.93.2022.06.15.03.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:21 -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 v3 11/23] microblaze: Enable REMAKE_ELF Date: Wed, 15 Jun 2022 12:03:48 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 --- (no changes since v2) 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 53a7c2a48da0..41f8ff78d9f5 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -445,7 +445,7 @@ source "arch/riscv/Kconfig" source "board/keymile/Kconfig" -if MIPS +if MIPS || MICROBLAZE choice prompt "Endianness selection" @@ -457,11 +457,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 0875208cec62..0fd6239514da 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 Wed Jun 15 10:03:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643576 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=WQ1aJKK6; 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 4LNLYT5wlgz9t6h for ; Wed, 15 Jun 2022 20:06:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0991D844A1; Wed, 15 Jun 2022 12:04: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="WQ1aJKK6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3334B844A3; Wed, 15 Jun 2022 12:04:27 +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-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 0F3208446C for ; Wed, 15 Jun 2022 12:04:25 +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-x634.google.com with SMTP id n10so22167256ejk.5 for ; Wed, 15 Jun 2022 03:04:25 -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=RyAF2xd4Hb4C8EpLjwqmXNodZhPy1T6CU0Ah81MTlxE=; b=WQ1aJKK6kwnksGfmHN7mPezc2rcnyI5gofcN0PKoEDAO4AqPsWG2FnGwGSJh5i6cFe 3pMRRVvqbXsf2PMEcA33wEd1EjVs3c9XKUsIueuvjgt8AAyj2EOIxRqkB1SfwJLyPWfh 9zUzddF5sn/b5/8r8I15gSL1Fttq77YVIv848FIzY6Wu3K4H1zSZzUiVbR5TtdBCIfnS GYeDKDEsGH+hk83DEJzW0XY/YYWk8Z5nbSMWqZxcaxA2pahqhC+1H8iFDSkD3GipTiT/ DBqIb+2IM6xGxiqiMxnIyQv+LuCRqiBWbVu9UBrVLSzStCb9AHLygLgKKGfr0pli3h4V IpbA== 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=RyAF2xd4Hb4C8EpLjwqmXNodZhPy1T6CU0Ah81MTlxE=; b=SCpg+TNs/cQ9Pu7FxNg8uG4N5lqf71mSlh5jgEM8h/je9CnAGvEM2QF9/D4MGAQ45o wRI74LXaTow+9HvURzF4xkRJjSJx61ozp5GAlVymiM3fR+wI80lfEYbLPyrYw2Q2x0Wt xCa+djE2Kq2wySlu5vNPV/2jJECOjPOFU3n+FlFHczvmIhhCk9OjjAPbKf/I7T2SVxQx o4GivQVMnm+1h4+1237hj/ph1R+pP/jl2gxKDcoVBZN+WjutnBrQW69xWgLKAZSFXxHe SURVpd9piKV0rjQo63KqMono1vHro3JJoNnyIcS1jkZQTgI5Sqb67xzdUcqFqTvtXWB1 ODRA== X-Gm-Message-State: AOAM533z/C7gpYg3oKYEmCKjHAeOHYsAb2E9iMxmn2myekGyvPScukGf In70xVch19etPqKDlh9pYYfofDEs3zaQDA== X-Google-Smtp-Source: ABdhPJwodnpAsuqnseuw+jpnG6uPlmgOM1xBf9y6h7VM729FI2EbSZ5b22YDtiuft7BytoyXsapSBg== X-Received: by 2002:a17:907:3f97:b0:711:d61d:df9 with SMTP id hr23-20020a1709073f9700b00711d61d0df9mr8269285ejc.644.1655287464360; Wed, 15 Jun 2022 03:04:24 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id fw37-20020a170907502500b0071579abcf3csm4931971ejc.111.2022.06.15.03.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:23 -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 v3 12/23] microblaze: Separate code end substraction Date: Wed, 15 Jun 2022 12:03:49 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643577 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=c52J4CE+; 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 4LNLYg3tRMz9t6h for ; Wed, 15 Jun 2022 20:06:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 284F5844C3; Wed, 15 Jun 2022 12:04:41 +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="c52J4CE+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4E92844A3; Wed, 15 Jun 2022 12:04:29 +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 6F0728446C for ; Wed, 15 Jun 2022 12:04: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-x632.google.com with SMTP id v1so22112325ejg.13 for ; Wed, 15 Jun 2022 03:04: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=sSOfhCDzYe8wwhwsc8DY160ixzidP+0QfnDEEWhouJI=; b=c52J4CE+6zsnJJBrMdJykSqv1HQLzMOZ1aO5tZt48h1bD696ZVqQIikt+2pUS9Edxv +y5vDRP/oiSpzf/s6AJQpmQPxwfuyezD4zWp2t2T8UJXWk2a5Mp4qSmX959Q36Atby05 zo2ctYc3av7kjRANFrwVZw1rwyPybTZKbDRwmVli8cK3saNOeVz0U3es5bUvhdNNceYC OIf5jYUuBbCfYAgStlHrZvRCCKprAojd66777HrzuUkhUNsX8l1aSF327aEn9ByMenVp qfEga0mR53RtTZbbK3GYsrphP9e5IKnNmBWgTFPqBkYDGCAF3hHXOary7XNDbFIuk9Bd HC/g== 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=sSOfhCDzYe8wwhwsc8DY160ixzidP+0QfnDEEWhouJI=; b=CJb6IKnCR0pkm3Rx6rx20noqjSK8/uqv7/QGcdBoGNkb5fhBQU7qtLbNalLgA4s6OM 7XqmfTyZFRccXI0tSTirqeaVl1aWlW5ok758l3FO5oJV9wT/v84lPMz4iSac/V+58FPX Fil7GPfwzL0GIXYmyo73YJeE0b4+3MDdSZ4fsgyLDYlMLhv9g1HfdoxpA2Kbfepuh+At GG4L2Q1r2YjxMN/TNhINRDwliLnLvGPtCW4YPogmvGVRmKtbEO/rSUjghwopK1hcw7oo uK2vttmdfyS4R7jN2pJARe4jQSQlSI+8n8u+1U7PwQZ/LtsSWPqSRL4VMuYOWQB/ySSf DjJg== X-Gm-Message-State: AJIora/9z5tpTip0VnceRzsaZrH4PS7mEkZevOsTr3gW+TFRpUvgJTfI kgUkGk8ndAugewKcEdmPtdS8tSXZEhhfWg== X-Google-Smtp-Source: ABdhPJyxUfcCAFDCDXw3sDGPyfcYQXGrqol9lZyYWX/65keRTtXsJgy0+oqzL6E5Pmtxr5n+XVc+JA== X-Received: by 2002:a17:906:37c6:b0:70c:f9f:f0c5 with SMTP id o6-20020a17090637c600b0070c0f9ff0c5mr7823460ejc.743.1655287466630; Wed, 15 Jun 2022 03:04:26 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id g12-20020a056402424c00b0042dd4ccccf5sm9146628edb.82.2022.06.15.03.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:25 -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 v3 13/23] microblaze: Change stack protection address to new stack address Date: Wed, 15 Jun 2022 12:03:50 +0200 Message-Id: <143e244c828910a400b5589b23a6aaa5bdcc0fb4.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643578 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=emo1/MWt; 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 4LNLYs6KvPz9t6h for ; Wed, 15 Jun 2022 20:06:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 582B5844C4; Wed, 15 Jun 2022 12:04: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="emo1/MWt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6BFB8844A4; Wed, 15 Jun 2022 12:04:32 +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 EA6CA844A1 for ; Wed, 15 Jun 2022 12:04:29 +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 eo8so7139868edb.0 for ; Wed, 15 Jun 2022 03:04:29 -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=VZjFfrgoWTaV3LJ+y4L1XSyosWG8Qpbt8OsBA1gfelI=; b=emo1/MWts5GfhG/v1WITmcYu8CICszf42EbUY5ZXIENwO2HJazNIB2ff2TfLbGpXxM jcalWRdzZceXx9HH7qK1FDKcO29pl9IWFppXvTRvy/a93i0/QWYp+URmlzOkFc5ZJijG 0pu1AH7/1XPjwVC0f7rvuDRrWLLZzJPZh4ekpYHM95CCBQII13fBm2UqNt8D81Os8QWx ZLUUOnmrIUYjlqwcf5nbQ1Ey24PAE7Y6ms+ttCVn/6I9WMvcladWhAfUrDTC5lGOCu2+ QsxDDD4i7me16ETimIPiXnCIMR9OmcRlRVsO5Wf8x2t5eD/mPaLQPgkh7EH9+yoe4Bpl L+8Q== 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=VZjFfrgoWTaV3LJ+y4L1XSyosWG8Qpbt8OsBA1gfelI=; b=0aKcuk0UDOVrBJr6Y+9GMjpYL5NfOm2GYCKYZ5wJ5jAFJKqglIMl1B/WeroTrlbz0R Kbck3pHRjQTo6v0GgaFjkr3ic5QR2dXoF026zOTarRIZc7R2n10UrdVNToYohCSyqfy+ uhI32guc+Xo40THuKbukdjprRY4qMthBOWKv61TyjfGoMa1UrXdUV/bvqDphlKl56EcQ ZiQN1/E00/BPAQOdZlCAc7NsOhLXUWx6PLt3CrgO2jb41J2SFxft1cfneMiRWua6f7Au OsCgacTcuJgV4rFnKn8HBSDEWnDiKkEO/QOlZDCqhdploJk7/kJnsIOvSKlDt6nCABMJ Y2Pw== X-Gm-Message-State: AOAM533wWNYL6R1hwxerUbBbhHzxWG0KDolHUlImPxZWcz6IPW62/4/+ 9/c/6F3GqoOSVek8apR3ZmHWc2ZJu4PHlQ== X-Google-Smtp-Source: AGRyM1t2Hil+AJ8cY5GAS/mFk0CHMkl3+goBlMaG1pnjsSWF48NQu/l7RS0F/5UJoPznxIrEgqk+cg== X-Received: by 2002:a05:6402:ca2:b0:433:4a31:d0ee with SMTP id cn2-20020a0564020ca200b004334a31d0eemr11862492edb.288.1655287469197; Wed, 15 Jun 2022 03:04:29 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id p7-20020a170906614700b0070f1b033de4sm6053783ejl.200.2022.06.15.03.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:28 -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 v3 14/23] microblaze: Optimize register usage in relocate_code Date: Wed, 15 Jun 2022 12:03:51 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643579 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=mgg3Rof5; 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 4LNLZ41B19z9t6h for ; Wed, 15 Jun 2022 20:06:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5D3B7844D6; Wed, 15 Jun 2022 12:04:45 +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="mgg3Rof5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0FBE0844BB; Wed, 15 Jun 2022 12:04:34 +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 9AC08844B1 for ; Wed, 15 Jun 2022 12:04:31 +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 w27so15350407edl.7 for ; Wed, 15 Jun 2022 03:04:31 -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=/1f9n0nd7OMxqcDbecyk8IQlRj7O/M19gnjS+/3QcqQ=; b=mgg3Rof5E0pA41r14xZ66uy3Ih2vh0UiQqO6uizuAdknf3EXRUmhdY0GHb4WNjt5mY yFqzyRNYamz8dFdf5zLTko+2qjwLIOqTAQcatIz42cAXSmjI9d0DWM04JZd5psagyC7i GVCGjiljrM9B2OKKn6DhXvR6e8zuH4vZ7dPhC0MsH7VbZSh+U8ocGKuGERvL4sS2mma1 o9ZK1uf360b5bIsWTIwMvPAWCBTKTEsLOxakYgIr/hQkHtu6bwIfxEn4aosucS+kXT1u 1dq8DxqBv4whF+fWFC3sc8/JvgoD8MQFMtN6R8Hkb3cMRo8DDn6nQHF8Ubm35R0Wv7Nn 10HA== 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=/1f9n0nd7OMxqcDbecyk8IQlRj7O/M19gnjS+/3QcqQ=; b=K5a4qukq+Ky23dkfPmJ7ax6YOhp+jcJQQ9af8siIxX76DIm/t7LGDiPJYP5AHDEheD NFFJ0VgLOH+67Xb6UeMAVRNwCMmGZ7PBaM0v4Yuyj4l8+pBvWW3HLiKN6ttmP2x/uC0E VSbfwEJk8BpvQyQGSJSeUk+QxMS96CGkE+xAAYALHaubUoe28LEh8Y/mxFPsShyeoOdN aIHdQGAb9t9jm1yM9SjqJ1VkYDEAYKt1IbKk/9W1P7heyP3VnfdWPuhV9kWaeqhmQRmK BOixYEnsdhIOxWL0ixmekUQukgbpDvl9AF5A0Do2kCMH2OMgiyWhzT0vIfPtmn3Q3G1G SF1g== X-Gm-Message-State: AOAM532KBFAbOxKkJaYGc4s5HDF5ctRh7lYust8PxUVHpRCw3TC2nqRO kifTv5cifb+3zNP+DbFUaRaO88JPBBsgUw== X-Google-Smtp-Source: ABdhPJy/yBGN8AslayX2ylzEryXFHTbEKPrcnN+uX8635omK5rpCovsYec/iw4O40F725CFcsSJiVw== X-Received: by 2002:a05:6402:42d4:b0:416:5cac:a9a0 with SMTP id i20-20020a05640242d400b004165caca9a0mr11689872edc.86.1655287471143; Wed, 15 Jun 2022 03:04:31 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id ge9-20020a170907908900b00711e60256cesm6042428ejb.196.2022.06.15.03.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:30 -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 v3 15/23] microblaze: Remove code around r20 in relocate_code() Date: Wed, 15 Jun 2022 12:03:52 +0200 Message-Id: <2a7f9cc335141928d4e1629a92ae3e3d108ed550.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643580 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=CerHW0GJ; 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 4LNLZG6FM9z9t6h for ; Wed, 15 Jun 2022 20:07:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66A48844DF; Wed, 15 Jun 2022 12:04: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="CerHW0GJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA698844AD; Wed, 15 Jun 2022 12:04:36 +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-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 C40A8844B7 for ; Wed, 15 Jun 2022 12:04:33 +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-x62f.google.com with SMTP id o7so22187177eja.1 for ; Wed, 15 Jun 2022 03:04:33 -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=7zCI3sCpSLnJ9gOiW082rzU3Y25b9X3S6KBcQL0wylo=; b=CerHW0GJvS/U7NX/OaQ43yel2eF+Ht8U6le4jm8aASyS8jvUTGKPREiO0l5xaYHkKi HCSAsXoIrvhVKqj8XbWE/IVYzO4Z7AfJhuQS7rZXuOPAsqeAK4DOd8MfjWk5ezEWLlRQ zfrhIelgVeJhf0YVolm3Y5oRhX5plW3vRtcp+nnxNb+CK73zKZEq1KOOMQ9uYkXHsagE 608F+/GQqQmOvIBLY5S7CJGs00FNHo6L+IlpLupxF9UEz3mdhCGH9o3S3sfn7y30kz2s fJaVccJnma6MZANcJ8xNcKfJe41+0xLzBucJAwrc0kaAwLc4OfwRxjVQ01Kpgz86AZCC JcQg== 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=7zCI3sCpSLnJ9gOiW082rzU3Y25b9X3S6KBcQL0wylo=; b=K2x/0fUq6iLnj1ItjxTTFCIaHQA5uwl+nJfGjMo7H4sA2RMyikuIZ/LTfCVYEtjMLZ DBlzVLnCAMIWUqRis6Z4I3Hlwd+p71DXAEJTyCSEXltQjU45n18ay1/T2V5mDq0SXgou Zy/HWDmy5+G5J58t3LoZoqqlCfIe+LHVwWqcUFMf3sEKP2JIwQZqqXmUJ6lqgyzGGtIh s8dCIkN/IB1XhoVv0TY8QxsPCmW4/7p/JLjGWKcsA49Xz/mLTq+5klu4dquF/RQlKhe3 3+LfhQZyk/eBrmaGe34FpKFSokRQGqPgeQ4zqnE/gji1j1xVarjIabhka2orFb4nnlAi F2Xw== X-Gm-Message-State: AOAM5319w9KXszFKGLum6PNmVT2GhwPaZYosxoW7EmmEi9e/QZ8mlGjk qnoJWV/3oclEEMT8l6QD73WsksWxXH737Q== X-Google-Smtp-Source: ABdhPJy1l2TJGavqRmWHTOFqTTam3/WLrWH9A9UvyHk/Vcxn/CAUeroh9V3E4AHVdSiRKaZ8sHQ+Ig== X-Received: by 2002:a17:906:7a13:b0:712:fe7:8f1f with SMTP id d19-20020a1709067a1300b007120fe78f1fmr8331151ejo.98.1655287473248; Wed, 15 Jun 2022 03:04:33 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id n21-20020a5099d5000000b0042dccb44e88sm9109499edb.23.2022.06.15.03.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:32 -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 v3 16/23] microblaze: Remove _start symbol handling at U-Boot start Date: Wed, 15 Jun 2022 12:03:53 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643581 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=U5NcXyCv; 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 4LNLZT57dsz9t6h for ; Wed, 15 Jun 2022 20:07:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F452844E1; Wed, 15 Jun 2022 12:04:51 +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="U5NcXyCv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F3BE844B3; Wed, 15 Jun 2022 12:04:38 +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 9BE838446C for ; Wed, 15 Jun 2022 12:04:35 +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 v1so22112325ejg.13 for ; Wed, 15 Jun 2022 03:04:35 -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=HHn5YZe9TJxpReTWRnM+mdVX0gVPBjQ/hegbrYYrLTk=; b=U5NcXyCvheT0OstJcaXInmeEc6rU/G4OxplRVNDT8gosBKJPICNwpdd6xwIYQ7G3B7 iIKMxlG0KQMef0LIJsXvyVcR5Gc5pIcJOralVgAe7MtVzSjacah4hkoQRk2Miagu28MJ 3SfeIternsEYJijUazMMDh+3c2cXcYRGqXJMtCQfE7fHcd+ha/sxx8Z7GTojv7ldR45M 2RFPIymzXSiHEr+QpXRJ242F4R89y1TOudKkXQAptEAhOCaNWYX5tO2lzZbQ9NYKWNTk jA5K9hOjf3OUtpR/xRIG/4CBQhVRlNTmijpm30bM58B2L9QH6y9ZN77vVn87/+Ltuy0/ Sjog== 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=HHn5YZe9TJxpReTWRnM+mdVX0gVPBjQ/hegbrYYrLTk=; b=bdMv7IRu4mCXD2EJ3ZtsoDe//YoBAkdZ02kkvUUXd3fw/LvwVOsAoEwlJYxPeQ3H5v Hidi/lwlCHowXXk5KwfVg6aVF1W91Al9OTKyKYrfbosYV98srBOrKQHiVS3b9FMn+6E8 lJAqGWl/kmQab4ElOlPlxFfFDDXMDhNkc7sOLkYXm8+JQA2WJ1QHI6Vf8KdXKh4Jo8hI nAA50lSCX3Z2CU7rDXwdFF4+IefKVaoF+5dcfiEurwMlgP6tjhs3f+dWrB+UE4MMcpSl kAdl/r3rbqAa+MMyP5RM+emWSVIRL4k9u9bMIW9Zeb5Fuh7jtjKX7kkQopE6o7Rko6Xn 67yw== X-Gm-Message-State: AJIora9fa8Nl6Aa++JbX8L7YwDfaaAwMBN4X/XVp1wcNIkA1WZtqIHxQ IYJ0hLISMqGur/7m9GPYN++Glr5eVtX3eA== X-Google-Smtp-Source: AGRyM1tljfXjF3PPgVwQg41P1aPar+laMfdd3w5Kc0n/5EPWaU3P7p6VW+YlWDsMWwe9XSJUioBDwg== X-Received: by 2002:a17:906:1501:b0:715:76d0:862a with SMTP id b1-20020a170906150100b0071576d0862amr8087292ejd.681.1655287475134; Wed, 15 Jun 2022 03:04:35 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id y17-20020a056402359100b0043158c608e4sm9307384edc.27.2022.06.15.03.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:34 -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 v3 17/23] microblaze: Add comment about reset location Date: Wed, 15 Jun 2022 12:03:54 +0200 Message-Id: <80abf05e8071859e9196b6e5e7f1d98738bd3f7d.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643582 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=Wgsg7mhg; 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 4LNLZg4HlMz9t6h for ; Wed, 15 Jun 2022 20:07:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A511844DC; Wed, 15 Jun 2022 12:04:53 +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="Wgsg7mhg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 860D4844C9; Wed, 15 Jun 2022 12:04:40 +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 80ABA844AD for ; Wed, 15 Jun 2022 12:04:37 +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 b8so15320129edj.11 for ; Wed, 15 Jun 2022 03:04:37 -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=gfxWF+FbAZfqr6AUPukHdvTbCVhWRakSDQbhL27NpwQ=; b=Wgsg7mhg4zjjd8wk4elhDeBP7EwlN0asHoLURr2MlBNEIuoITJ/SXYAvR/0N7qUJQe JafQx6uDSQXLxwkMpXqyzVZvtjeAbp+1Vnp+bej9iUp2lc2trqi0R2/WPVFhfe/O38ll qH2NORnuBIHQLdW9iI9WN+rmKN1zqf90gdkNRtMrfE+5fPQtjm8tgYyb9StsAmGnz9Hw am5ZvnqY/6K+J8xfUzYJahFBqZgUrcwt8sCuBMU9DSAXYn9y1Mu7Dj4UkDAg2lQkLbGh ZHskCk8Zo8uAeBVWLyrAxMTvHVqFqAegvLnrlyZ/JUjRlo0QgpJ7s5/Yrm+gX8VU3kYA zTUQ== 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=gfxWF+FbAZfqr6AUPukHdvTbCVhWRakSDQbhL27NpwQ=; b=GRQRnr2PDOOUcfp/RtvGkd4tybU9SwadDsl5PVehMfDQx+gGqLXxJRB8PdXyYGApVc v5NPrqD4vnZyZc9ICNpTVJ1o8MraTvivoUl4U2C4tUTUYUS3Zv9mT07S+mkj05EBAKjz BUIFAj0afr8RKNudoFnMK847rodOX7WVgeJsOxuPR/xNBUInrJ1WiJOX1SJK66qh2E7M 6Bsgmkul1TB2V6d9iYjHUpl42gOjgGzfGSImGj5zL525VUvQq0Drs7RuICEofXLnvVI4 B/o7QVsf9DRZV16a+tNV4145xyykaXresqDoZU2Xj6GcgtwKF48MlfpN6TSSGZYTkezz aJkA== X-Gm-Message-State: AOAM533X6iLtYi0RUqLOJpaTizZxOfa1ad2v0iICj6yWZ/XkGExm4w7M dEEwZR44W94MKY6B1ChqlpNZD5obaBsA6A== X-Google-Smtp-Source: ABdhPJzC2yffwV2BI4kIfhIp7Ga6ZDQyc+HvWQUNOABtcQgPcwIjlZsmZ8pQItzdRAgVplbx7635jQ== X-Received: by 2002:a05:6402:3490:b0:42f:b592:f364 with SMTP id v16-20020a056402349000b0042fb592f364mr11719622edc.66.1655287477054; Wed, 15 Jun 2022 03:04:37 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id d1-20020a056402144100b00431665f1203sm8971036edx.73.2022.06.15.03.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:36 -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 v3 18/23] microblaze: Create SYM_ADDR macro to deal with symbols Date: Wed, 15 Jun 2022 12:03:55 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643583 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=MGBYLHdn; 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 4LNLZt2Ts5z9t6h for ; Wed, 15 Jun 2022 20:07:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B557844E3; Wed, 15 Jun 2022 12:04: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="MGBYLHdn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8C2D844CC; Wed, 15 Jun 2022 12:04:41 +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 564E1844C5 for ; Wed, 15 Jun 2022 12:04:39 +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 eo8so7139868edb.0 for ; Wed, 15 Jun 2022 03:04:39 -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=Fp9V38kz98OjcC1GXo89dugvB3KGTIHmNym+7MbPd+I=; b=MGBYLHdnaJpC+D/+w+Ym+8+trhtddv3tVRSOwzfaRFPuUtR9BBkGgtsCQrPO+XXvXu 5fI88scGO2ZIRY9WD7R5d35WnWzlGUo2TfhOfvyNn1atgC8jibGkospub5Iytv6blE0V 7vMzmcBxXlVr48BaO9UTAt0dC6I4szymuVMrEI5GuriK7INc8quaBfriqziw2z5vOo9w LOrPgQEDTitxrGODuYZFxo94+wl7eGFVT3YKF78DpefiIqrkurHu3WtyoUXRQ0z0ZNnO z+DmfrOGzPHNFAUawv+udgk7d8gC2JCuzBp0BYgMQ5m52ABBhVbgPOqPk5u1nuETyU6W no4A== 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=Fp9V38kz98OjcC1GXo89dugvB3KGTIHmNym+7MbPd+I=; b=EJvXlqid2lwnalsYp+zn9r5kKHfnCvRWocc0mhHGvKnqtCej0v8Fd/kgp9eGeMSkk1 6j+fwjua9zDv0F0Zkz2lu3fSPDN9VYQkYFWOpUFNiaXKIz3HStx5zqow8DMqdlYsJx0i a3WuNbLUcSW9VgEO6uMBAlnd+D2JjOHddT/bI8dYzICEcZlQ1uYWo5I9mP72FxsOrJHF EldxDrB3AcBuG6JhKtNEHbu6alPfUKkSPFKKxkHN8pDsjjBIWjQOBADwba1jDMXodPb4 hqz082aLP8KLYZI3GmjEHwU8pM3021tE8bDMj7uq+pswMuR9Cb12oxt4mwIizeVkywTm Vi5A== X-Gm-Message-State: AJIora/2mUlPYnyOWKwkl6DJMqwA5Ap48z7fVbV4B2GXYcU3LmmVrP9c 7PYeA8D5QTjtSM/JXJaVK5yFkBrZnbLGpw== X-Google-Smtp-Source: AGRyM1tcs3x50sAVg98KG6VG8SJ3N/tHLdO6HG4xKNMzrImCczn9awBVapjf0gE/aM2+4L/Xe/Darg== X-Received: by 2002:a05:6402:25c3:b0:434:dfbd:913e with SMTP id x3-20020a05640225c300b00434dfbd913emr11721894edb.27.1655287478816; Wed, 15 Jun 2022 03:04:38 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id gl6-20020a170906e0c600b006fec63e564bsm6079988ejb.30.2022.06.15.03.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:38 -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 v3 19/23] tools: relocate-rela: Extract elf64 reloc to special function Date: Wed, 15 Jun 2022 12:03:56 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643584 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=3bvC2Yev; 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 4LNLb46rBnz9t6h for ; Wed, 15 Jun 2022 20:07:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DBBD1844EE; Wed, 15 Jun 2022 12:04: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="3bvC2Yev"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3376844CE; Wed, 15 Jun 2022 12:04:43 +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-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 792E9844CA for ; Wed, 15 Jun 2022 12:04:41 +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-x62c.google.com with SMTP id fu3so22148450ejc.7 for ; Wed, 15 Jun 2022 03:04:41 -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=VKUw6J/gZfUvpP7Lb6U4eb3qNPtQ3DikkajbnXxO+kU=; b=3bvC2YevTa4SIXE7KcBF8NK3WyEzZqL1TkJiq0HP2lNbBSarKLi4M16IFxb17vxy7l 6GrxHHJLGkN3V6Q1LA1mvNCOD+U5h+JsLgd72hsqZdQP09S4hWqzJxGE/hAY3WYqXmoB 8HrGaX4cmFfbuS6SrngCHnL4tQxtM7bo4OIx57oI+bc8ulIVad1wxamWVw4aXFHBXHCB DOPVTbzaNjokcy7hbrygvrAYOqEP4tzYwayrM1zeyv1IazODQNXgHFILtm4R5RNx62SN SscHofmFtld6u2jCi8iFHKGkVd3rex6D2MuDS+wnkdqSviZ/Go8VN7eij+qgnVQTke/3 a2Ig== 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=VKUw6J/gZfUvpP7Lb6U4eb3qNPtQ3DikkajbnXxO+kU=; b=ToqZ0MSgLkXhkZKwn3AO4KiUCiQ4Y2ocztJKN7jVw75qWhGq3pxwdlDN6H4FwjAD04 wdSJH9XdTi0dEpY7wCBMjCgMUIrRPlQ0Y3Co+kewDpund1SSj66KYtfl8ZICXk5r7Npi 9tHRtrxMqYFd9ucdrJpyEWIb0xda70hiLCde7tQ+l96OAwRrjRSzV5h7ZER0kqLuKX8l 6eO0zQj5q6gYbXog56SuHmPO1zJdgwt+52kkB7uvfoonlE+W4zHkPQXS5HQKKSCwmuFN E/UOE4KYMWamJQSIwKvHOe2O3qaXDN7LG4GqFYW/PNUhFoajxwrIrJfJ/cvyKdSe0xHQ P3yg== X-Gm-Message-State: AOAM531wHDfdH8C0NKSqnEa5sQvLo43YkY8JyHbOHnZqj7nei6YuMqcR tX3z4Rkes/kkeiBNsKqsMeCJz+80iRj4EQ== X-Google-Smtp-Source: ABdhPJx4Im60q5NV/xJoabHOu315FDZOGfQrcm8Wn47fAYblyaHnRRFs6RevMxx9SBnptAi3fNu5/Q== X-Received: by 2002:a17:907:7da2:b0:711:f36e:b855 with SMTP id oz34-20020a1709077da200b00711f36eb855mr8403512ejc.308.1655287480833; Wed, 15 Jun 2022 03:04:40 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id 14-20020a170906328e00b006fee961b9e0sm6023702ejw.195.2022.06.15.03.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:40 -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 v3 20/23] tools: relocate-rela: Check that relocation works only for EM_AARCH64 Date: Wed, 15 Jun 2022 12:03:57 +0200 Message-Id: <85158ecd602d340cde081f0c980350183b74de18.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643585 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=aaL2BJvP; 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 4LNLbG6sXXz9vFm for ; Wed, 15 Jun 2022 20:07:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA936844E8; Wed, 15 Jun 2022 12:04:58 +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="aaL2BJvP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 655D7844DC; Wed, 15 Jun 2022 12:04:46 +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 6AF65844C0 for ; Wed, 15 Jun 2022 12:04:43 +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 w27so15350407edl.7 for ; Wed, 15 Jun 2022 03:04:43 -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=xeOjMHzua7zuiVsaZt3fGucYfyGlRL4XFrXMPiNYQf8=; b=aaL2BJvPYvdG5+dir6smLek7I2mW9JGKuFSGO/eGPmApQYrhwC1QIZ9eJqQp+KmHFz OZ0212DAZ/aVly7GBHNiNkzLCnFFZT6ocmwnXotkHotbtuogfINyNc1kGjVYpong5s2q lTl4e58U6acOhIkuNZFF8Fc2GXTFDLMXY3LGiGKDFe5KCWGhxSqZZRiymptY0vgd19iM 0uAeXD1WPpfgn9EjbuPpsNt2jiUWO8F+naszraQZOmFhxigA3wJhpBlPCYbkrDd+dfp8 gRsG9VsHWjMaHbOqhyow4bmygS88KZ5PCfNQhJVHxH51hxzv7IkhmTq677YweL/Ma/Ky NzDg== 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=xeOjMHzua7zuiVsaZt3fGucYfyGlRL4XFrXMPiNYQf8=; b=WNXlCHtWdNUnPKWWjNHUq1NCdm1y/dr6wkaF49hsEPHaH+9Ye1YF/WmIXCNbG+wsPr mVuuHXEmFXx30LCcEFTgv9CvX3jOS6COoRfmQLhvCfTlZKUF25IdJ/kfoT5/C9MaClTp C6rZC2oklmtbfFepGqE60H/CivWz4XCFpRBWDZT9jjsA9/lnvNs3CE5NBhf3E7DF0bl/ TsU87tTTcqPDLTULK1hbcWY5MvWwY3AtO+ACBPZPMJ02/QDpN5s0MiUbj5pAg/wVBwdh rYgRB8jZWn+cOO0O3wLGrmOHDhhdDcwnIYCuQp++1MicqR7gabe+m+r5uvmVmvw9proJ 8/FA== X-Gm-Message-State: AOAM532zPT60f42TofXT0FLHomyh1lMT8K6GrY4wJiRLFLYnDTdQvFBk oPnRg8xOHB0II6tGR9na8tAsOBBlNWNebQ== X-Google-Smtp-Source: ABdhPJxaTyEj5zk8Ik11OUJbBRj27o6ZPaP4TF9CnklGnt+iGufDL/wcDzDyu83BFu4C9bwX73FlSw== X-Received: by 2002:a05:6402:26ce:b0:431:52c9:5a9 with SMTP id x14-20020a05640226ce00b0043152c905a9mr11785076edd.61.1655287482737; Wed, 15 Jun 2022 03:04:42 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id bq25-20020a170906d0d900b006fe8ac6bc69sm6193331ejb.140.2022.06.15.03.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:41 -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 v3 21/23] tools: relocate-rela: Add support for elf32 decoding Date: Wed, 15 Jun 2022 12:03:58 +0200 Message-Id: <492b086f35e57e52a286eb19b130e92745b4202d.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:03:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643586 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=20gpmvPj; 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 4LNLbW0jTmz9t6h for ; Wed, 15 Jun 2022 20:08:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F4D4844F2; Wed, 15 Jun 2022 12:05: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="20gpmvPj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 69E15844D7; Wed, 15 Jun 2022 12:04:50 +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 48434844D4 for ; Wed, 15 Jun 2022 12:04:45 +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 w27so15350407edl.7 for ; Wed, 15 Jun 2022 03:04:45 -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=UTJK504EjPY/IvCBYqOeE6cLJxCoYDVQpeAOdsvxS8E=; b=20gpmvPjNDNcJL2n/xK7oOFgtafs1RsjhCvH+73yHq+ssQQvi9Sdmd+wsE6PzzwxyY z2wus4gsargjJRx2kbK6LSjKP9EIlGNG4fhX3IN2JARQJeSLzIA9/NO5+sl9WmmtY3lV AX3LCgXS3WL1lsCAQCSZQdg65VN0H2mfKOLvuFpm5WDyOTmJbFR/gz9i1f7kQUEe8J14 SMiZPYw//fpVqb72bK6vOYcYEUenRuNmgo31M6Qcee5f7p1d40rUR2Iyzmhql3fS1bg4 U4nHzrMAytwYXKHT/279tTXOAfhaeLFpFecxT7WBr32ZcIYBg4bhi/O7Bvx8ykqHWAgy 38ZA== 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=UTJK504EjPY/IvCBYqOeE6cLJxCoYDVQpeAOdsvxS8E=; b=5/0JWT76fbAVdqCRXHEmTHkOYuxLN89qrS/wBvmd4UIxel1HKZelIHaF/V9koTz+Q4 gj0glPpIySgUMNmxnNTvvWJh/+s2jmMLKEH5pKpqCqy/b46HrO5s2h91g8nBkYWkeGz5 Rq7tqe1Bbh/ZMm9IKVAfGfWNo5+i5FWH/mkjvid9mQj51yNgaL3u1uuUXzicn3w0OT7D 7VRGxYh4VvHT6Q8Helwnc/hjjfKvGF6QV74KAP/wGUloG9xzJTD1ymFageu+fA+yM26y c4h3INFIJYZUJTU7I+IX6CqNH/5vgA12kuISqr3nhBbEI/UonDhsTydT/2LMipdj6yZY FNMQ== X-Gm-Message-State: AOAM530+Uv/OsvuCkrmdo65WJQ5z6/PqyE5cdlg4mNDKyVx6p9UT7bAA gwLLyz9NFcwkh5ihCoWTufcUwxMH2vPqfA== X-Google-Smtp-Source: AGRyM1tuKbPOs8iR5eHP9m80o0kXbbRIeFKEPsUdWzatzP/+AgNNEMpfvQP5wocdvPIfOOLTS4Qk3Q== X-Received: by 2002:a05:6402:3482:b0:42d:e063:7c1d with SMTP id v2-20020a056402348200b0042de0637c1dmr11916135edc.40.1655287484683; Wed, 15 Jun 2022 03:04:44 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id t6-20020a17090616c600b00715a02874acsm4445403ejd.35.2022.06.15.03.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:43 -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 v3 22/23] tools: relocate-rela: Add support for 32bit Microblaze relocation Date: Wed, 15 Jun 2022 12:03:59 +0200 Message-Id: <53c31e7701ff0935d32cbce4152cb08e595a1c48.1655287429.git.michal.simek@amd.com> X-Mailer: git-send-email 2.36.1 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 Wed Jun 15 10:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643587 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=GlO8oEDD; 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 4LNLbl0Mkkz9t6h for ; Wed, 15 Jun 2022 20:08:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1753844F8; Wed, 15 Jun 2022 12:05:04 +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="GlO8oEDD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D626D844CA; Wed, 15 Jun 2022 12:04:51 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 A820F844CF for ; Wed, 15 Jun 2022 12:04:47 +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-x52b.google.com with SMTP id x62so15349074ede.10 for ; Wed, 15 Jun 2022 03:04: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=HmbFmHnI8/1IUjPxGMN1KVQ8cb7xa9GvLa6H5piRm44=; b=GlO8oEDDEY29L6d//dGmWs/7xXYxchvI+r8Yc0EuBHZtbpBXdBSQRI+PYYHdXwavYj zqIn4SOMBfiKOwWkHEololEO+Qq+vQTp8nLRjG660lHJmpcECHIvkH3dBrJ0peTZvvAG gFds1gj3xK48fVD79w3xq8GZgN30jCSH0Wju64OzpmfYHltGnvUDMfrByu7SkG4bu8xk q/mgXJ5JSpnBcFPHp0NYe6OHlmkAN1B/uwHsgCbrR68iQRFqAK9tkjB6C+wEs8RPQZH3 NAalSqZTsvdyNNaKXYfbOdgnJSDdp5LGWxIC8L3yRYLkK+FtKUs0zJDDWjqkeYALde6f k64g== 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=HmbFmHnI8/1IUjPxGMN1KVQ8cb7xa9GvLa6H5piRm44=; b=h02mCb+XYfRbaKAFLMfhjj11yGGnlUpRi+g/zKsDXsIkj1Z9x0TuXUlPHLcoj9vnAR ItLmpUmeQK8c4/DyPSknrbvzhUEb+fi/fhRg/LDm0qo+/Cx6CUkyzJegdRLo6QSwjhQ0 BUYciEJXbLocs4O5tDZRofDwa9J6KXXt98dlF0AYlrVQO85DZ+6xrNy+6DH7hngQP2bL Y7w6yGS7T2Cbj2xApu0TcJR+4HPQ3QyKBh4L4k7js9RXYlgCp5dqi5VGswiEfc/uh6EQ yy2LY18SM9wbZUJ1sgzHkEAbwQgtCsNngDA5mJ9gCm6QFzcY+XkUHN4PYOD4iqObPdzw 2pdw== X-Gm-Message-State: AOAM532pT5kA8SMo8pyv/bUQTGRgs7sgoVu/R6g06Ynrjd8mBht0HvZE nWvPB1KroExnphCdbBZzdCnlu6DqX21wjQ== X-Google-Smtp-Source: ABdhPJzMn4peklkzp0/8l1S5uxkxxUfdBMQGzBnfuKs4Z0Df4RrQcu34CMjprmxJbhngVT2l+H6FAQ== X-Received: by 2002:a05:6402:11c7:b0:42e:c47a:ffdf with SMTP id j7-20020a05640211c700b0042ec47affdfmr11638287edw.113.1655287486806; Wed, 15 Jun 2022 03:04:46 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id q8-20020a056402518800b0042dd022787esm9163327edd.6.2022.06.15.03.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 03:04:45 -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 v3 23/23] microblaze: Add support for run time relocation Date: Wed, 15 Jun 2022 12:04:00 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 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 41f8ff78d9f5..d91475d24747 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -73,7 +73,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