From patchwork Wed Jun 15 13:20: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: 1643744 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=SMiFp01k; 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) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNQts0mrpz9tlf for ; Wed, 15 Jun 2022 23:21:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 460228425F; Wed, 15 Jun 2022 15:21: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="SMiFp01k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D3309839C3; Wed, 15 Jun 2022 15:21: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-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 D867284464 for ; Wed, 15 Jun 2022 15:21:26 +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 25so16083260edw.8 for ; Wed, 15 Jun 2022 06:21:26 -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=SMiFp01k73bR5CTAJy/2euWF3WO6z35oxRvlUUJDAZfD5yRFZaLLyjuppM90KQ7xgC AcrbWaq29JzyWSY6OIoNtnJIQG7gOpRExb39NYYCYXCATz6QP0fkfTu7M15Tobspuz5Q F1j9VI3MspdM339YWpghnlUVyk3THXYRhszBv1igtTUXo49xiT0COEBcB3x49dJoohMk blbP4qc2TvU1eiyxaDBfB/oSNJSsf4sCLI1S9JuVYP0mcFIyFdgANQ6/iNWZ36el/p46 LboQBZLRC5INuXJb31CgYUth0n+ykcTQiNbbBUxjZEP3nXWKzi3y7rtQrGVDcmL2FjMM lhSw== 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=68Au0h+4nsMdg1zlU9x3okflDC89F5CSUDD6zLzHKWczrdx9KcwrZWJm+YnemR7yt/ Baywdwn+zyz8GvcnyLbzCzho6cyo1IHGP35BaSxKw9cYXy+wqQkpzxPoLe406Wam8fFN 2JtAnAB+0ugH+v81JBSwJukVn5UTMYemmqoBFqsKmolzP70BRqE1Wk2yOcgsZf3/l6mU o3ax1HpQ3FUHjZgN+C4UH08yZ3CAgbo98ZF3xPcxJYmuwwsQHpdfkd8yFp42OlwHE4rs tB0RyLIhhJeTSmF2PBFpXeVgSTpd2YKXjCdkAgoiVWueBSpJFy43Wne2attLc+cfTGYi 1aEA== X-Gm-Message-State: AJIora9xVjSIjG3Yz6KHcQ3Rrn/B9u7/CPlo9br7t60V5fa6l5ERmOFB moO76CuHsMJxuliUZ+KoKNJAxtPdfk6ZTA== X-Google-Smtp-Source: AGRyM1tUc03fZJAAgf12QnI+BLU0V0dbshVSqAghj1VWoK4I40xZvgkM12tBqN1Rr9C9DNCL7OCpRQ== X-Received: by 2002:a50:ed12:0:b0:42d:d1d3:493c with SMTP id j18-20020a50ed12000000b0042dd1d3493cmr12496477eds.174.1655299286248; Wed, 15 Jun 2022 06:21:26 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id q24-20020aa7d458000000b0042aad9edc9bsm9282881edr.71.2022.06.15.06.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:25 -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 v4 01/23] tools: relocate-rela: Open binary u-boot file later Date: Wed, 15 Jun 2022 15:20:57 +0200 Message-Id: <9c2b4ebadbe83497db28af02f6af2623793ffdb6.1655299267.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 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 13:20: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: 1643745 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=cZKB3A5Y; 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 4LNQv60YKDz9tlf for ; Wed, 15 Jun 2022 23:21:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7675A84486; Wed, 15 Jun 2022 15:21: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="cZKB3A5Y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2FF784474; Wed, 15 Jun 2022 15:21:30 +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 6179A83E9A for ; Wed, 15 Jun 2022 15:21:28 +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 25so16083260edw.8 for ; Wed, 15 Jun 2022 06:21:28 -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=cZKB3A5YX9PR+uNLYBEJwW6dHbnraiceFsWDJITQDv20H+ceVxC7lamDrsgUDz8ivt 1QJUacDe7oUlvnWx1eVUUfcbBxowC1qQm9JgBedOAogveq9GddNlzKm/I27AcXixvh+p 2BDMge66NcTRj3Y7N1UrZM47SHhHA3bI4hgZTWldbmIjzYJZNtTbS0rkDZyL1PVhhoD2 h+w/FrKMBm7zr2KLh8Gaex+c57pMB/emhZ/mf7VNW+JkBkXT5nM+2ZcDP0IqhTv9DlaB mYRSi5Oq+kY4zokF34sBTvN2YjW5W8kCXN307SuJMPqKv0L1DWzQvj8vwqmE7xfPpFd5 rxiA== 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=jpE9I7INEX4aLWiabAdmustRR7OHwWbD3WgcAIHw8yIAWuNKpKqqteS2KZwHilTsa6 xLXbL9QJUnxgpFVwgniPNbO9rdDGHk5sN6rUSI8qpQRByFY5wSCm2Bu6aLjISyJNEJgW hqsH3cBYPCdzF6X4Sr/Ko6BT4wNkkE1WiPWUz7SFbft5C8R3GJFGr7M8RwKuSLTHMGOG XAlLzUpobfAO366a1Nsu9DJRcBKCEr1L4wk+H7O+2e6/gnw0Ee02eBH+iAKZ3refFMOX xbT1z/SmBYpK4Q5uM8WQ/kGVZahxbVr5kigpqzxrbHSzvEVRc8CXRUjYJ+bUMnFm6+3f 7Vvg== X-Gm-Message-State: AOAM531fptbA8oYAsttRztQhVwx+QFxP/0iIb3iLTrGOLZurtR8eYy0k 597XzDHJ7HsNAMgo+TW6XC/lmY71WgKKNw== X-Google-Smtp-Source: ABdhPJxeTgxBmni4Rrz1GYUR/tqHb7ZbfiSf9AiU2Xb5CdfyzUphmo3eDRQDan3Rwkk5FEVrPxMqlw== X-Received: by 2002:a05:6402:3222:b0:435:da0:3039 with SMTP id g34-20020a056402322200b004350da03039mr6512714eda.201.1655299287906; Wed, 15 Jun 2022 06:21:27 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id jx28-20020a170907761c00b0071160715917sm6247406ejc.223.2022.06.15.06.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:27 -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 v4 02/23] Makefile: Fix description for relocate-rela parameters Date: Wed, 15 Jun 2022 15:20:58 +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 13:20: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: 1643747 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=CPEp1RJb; 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 4LNQvS3m96z9tlf for ; Wed, 15 Jun 2022 23:22:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 28024844B1; Wed, 15 Jun 2022 15:21:38 +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="CPEp1RJb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF24284478; Wed, 15 Jun 2022 15:21: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-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8DFDB839C3 for ; Wed, 15 Jun 2022 15:21:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x635.google.com with SMTP id u12so23168774eja.8 for ; Wed, 15 Jun 2022 06:21:30 -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=CPEp1RJbQZrL1HZlez9d5ZyUOZHXHjm9q/eU8/zygmSUaumYt279OBezwSUfiUEqGL mQuGauGA3ysrodZ3uB8qvtIvyZZeI+npz+gB1jTIvR6uTY5GTya10exb73oj7e0BL6j7 1Y55v0xC1+X/k8DIXQusauAT7macNqxui1GbEe7cjtkYS89E34MkhMqOSTlBtbHbCC/O qoq7htcKnTo3Ly9h2yHEkiBEkiZRqCObW1jaRFQqsY3LZNvKb2dozow24TgdLEdoCeWT nwBqSl3SoTdeUXwxJSF/tFZMbreDJqAdBjZm3ezLvgF5H7Tok36cJIZhVe3wNn4eQlCa PxYw== 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=0nUQVT/bKpV7Fz1qUABMygqe8IfBCxEUyqVChGqogU/q/qK3wAhCxKXAe8DTLcrw29 ooaA5IUS0nAosU+k8R1GaSLYSPAz9LdHM0rfDCvufSnZYkIFzaHskmB2/0n5PwDWAdwo xHES9rUzYUAllnbdCN2zX2ItrD1fhPj8VrpDF1MzPQxZh+67zIdlPIAygmowl4OSLVcd pcJq9iJMZIdvOc7Me6Per9lSjZwtdGtf/2W3rjEJB3E1rV+49SKJQ9ywpvqOzL9lkroc 8sB5RpwMCwMM0h5jYdE+yY2e/ruRMy5iWtSJxS8N/1zf1bjBNtJAGfyHiaRjFEhoSuDF fsTA== X-Gm-Message-State: AOAM533NmSiVxJR5IQLmXtOdQsJsv5kusuRv5Iq+Cq9iBA8tyceu8bvu +4iAvix2Mw7zzytj9owsoJ8daHAXDGjX0Q== X-Google-Smtp-Source: ABdhPJwLx+yBoJ1h2w5dyeJUBwE869AENFWcs0nQS7cAacn8nwXenZ0kRThA0hplZ/ELD14cZp+f/Q== X-Received: by 2002:a17:907:2d2a:b0:710:7ea6:2b9e with SMTP id gs42-20020a1709072d2a00b007107ea62b9emr8754174ejc.371.1655299289853; Wed, 15 Jun 2022 06:21:29 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id d1-20020a056402144100b00431665f1203sm9333683edx.73.2022.06.15.06.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:29 -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 v4 03/23] tools: relocate-rela: Use global variables Date: Wed, 15 Jun 2022 15:20:59 +0200 Message-Id: <7485b163e92f8f3f754c35f7c88c3314f2212efd.1655299267.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 13:21: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: 1643748 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=aqErYDbp; 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 4LNQvj1512z9tlf for ; Wed, 15 Jun 2022 23:22:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04FD1844CC; Wed, 15 Jun 2022 15:21:40 +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="aqErYDbp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4321E844A7; Wed, 15 Jun 2022 15:21:35 +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 7A3CE843EA for ; Wed, 15 Jun 2022 15:21:32 +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 x62so16107373ede.10 for ; Wed, 15 Jun 2022 06:21:32 -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=aqErYDbpI/8UbwVTtWH7Ow6HJsk6yGlGZLFBCq3h88o/+10/QNs9xKLkNPayZ2ox+g iO3i7Owq6aXnXLZL2EV6gdjuf2TcpIHYITOkxtgxoahGeSFz9CQMIwi2rYAr/SftJQzv fv/cSOpLfkNa7ucyp3dDKvrMzeAZjt6puIgGUIcieApbPE99lgZr9igu4pS83c9QVCd4 gZ6BZuxNr9COo/YtVYdlPTk0aoQVLo0gwdqfaLeJEKBusAns42i1/BamWLxNdFwv+7Lw jcmHv+HHkMQneLhf/Tr459bhcSsnpMh1dlQkzo9Updh/ohetQWP1Y1TBKVCcmJbufJIk J/8w== 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=BtY+pez7lenyVexHhlFKxekAP7bi2Cn8vlof41QwG9L3z4pII3Io0K8jEZmJDECwOD VMRQVfoyWbHSrWZUqmjbJOmiJYRZpzXff4gXc38SPuUabNxE0delBWVqp4bdOy+MIiR1 w4TU7df0Tk2Hk1kIa8ylVZ14KJfbD/PJ8cj4wnfOe3JGChfAjaLGMpEcXSwDHNOfJ8XX TiCJ1utiHuC359T+yBhVbPyOa15+ctcLxOWfxZti9bl4K6SxQAMl3Hob+QAHP6hHGeKf NjtzFvFM5X/sQ46Cb1g/S3PJvurOIo7wDCr59rlOcz0OgBsm9fkRh9CJfSIllJGjB4d/ gLZQ== X-Gm-Message-State: AOAM531nnbcPOzpAdRDtj/oCt37MITNZLBC17InnYYj6taY33uAN4zYY KMGts2q0Jniiq41Y5f4SiBMFDIZgLQEGWQ== X-Google-Smtp-Source: ABdhPJwMrmtMNPo/sqMGnDu8H/t4l58s3+OeOpBPvHRYerJlAE5Hw/a5TQ1ZvggojiwkOWC/yRw4DA== X-Received: by 2002:aa7:cc08:0:b0:433:593e:7b13 with SMTP id q8-20020aa7cc08000000b00433593e7b13mr12909227edt.121.1655299291703; Wed, 15 Jun 2022 06:21:31 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id v13-20020a17090606cd00b0070d742804a5sm6297279ejb.150.2022.06.15.06.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:31 -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 v4 04/23] tools: relocate-rela: Read rela start/end directly from ELF Date: Wed, 15 Jun 2022 15:21: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 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 13:21:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643749 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=s1dsxAHO; 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 4LNQvw2q17z9tlf for ; Wed, 15 Jun 2022 23:22:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 86A84844BB; Wed, 15 Jun 2022 15:21: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="s1dsxAHO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3D428844B1; Wed, 15 Jun 2022 15:21:37 +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 4DA0184478 for ; Wed, 15 Jun 2022 15:21:34 +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 bg6so23331838ejb.0 for ; Wed, 15 Jun 2022 06:21:34 -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=s1dsxAHOzTES9HClGmpaeX6qPK7NhQm+U33GLpyDqkv9yqk83tckIWETcnFp5w/esg FEOshAlw1J301qJXuPMprtiFOKbrh7zyi7AnODSe8A51loBDar1N4SUt2iyt5TM6B+38 uBox8dJ7HnnAoxl15p42uZ4U1t2UxPMJpGE9X7n47g+Z8UUV4T1K03/TKzhVDyXDGPs4 YzxJDki0m5Rh0i+Z2fUBAbKEKB+Wc5zH3oaQgzCFY+2SzTUoQNphmIVZgfWhvGPvaEK3 a9JcTDd7LU0OosU7zcYb+tdbm72TtzTWi3VBizCSoY1j6fmoIxgKUyHoIYvK9ak8vM9R snjw== 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=x6LD/ZQN+8gaSnorlOu02qCfZtuKfMSixrYzT5sILVr174IduoHeTramD1vDxfMbvY BTZcDfq7LzOlLii5iu98e/hbOAxQ0632Y40YdbyTJwYCQawparGbeGqMSPLOAmmeqj2c 84V9Toczco86G4b1IGKk2958qrjZBlwJU8V5uJfRJp4bBwf2hXum0Dd5ZTmzVRMZnArY aSJGa+CmBkxGP95JmlUJqjQSfZOIMUWxU2ZlxkvSGSEzNquKw43yaLlow2pHqR6vtR45 GcODZ5C1YzBfaUPpivflUu3v7q9IGFSEUdE8quoookokmc5BDKkPeHqvPDhrKbZBmU6J Us9w== X-Gm-Message-State: AOAM531WZECeEVhZD1LMPVLzPVZw2Mpn1/Xlhqg4f/kYGIQCAdGTQYol Z1ZG6fxhYn3hNYMmlHSpvdkFB5zmpUOksg== X-Google-Smtp-Source: ABdhPJxRH0ywZ1nOKc8bzTaXi7rOZyzLepupHNK+c31LMiknA/GOYGamdKtE1NHIcMcHuG6IGTHCTw== X-Received: by 2002:a17:906:ff18:b0:711:d197:b942 with SMTP id zn24-20020a170906ff1800b00711d197b942mr8841332ejb.357.1655299293519; Wed, 15 Jun 2022 06:21:33 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id z22-20020a17090655d600b006f3ef214e2csm6441560ejp.146.2022.06.15.06.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:33 -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 v4 05/23] microblaze: Switch absolute branches to relative Date: Wed, 15 Jun 2022 15:21:01 +0200 Message-Id: <83a5103b85c1c2220cd3ab4d5365169c6660e40a.1655299267.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 13:21:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643750 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=4VgvCgWx; 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 4LNQw66xLQz9tlf for ; Wed, 15 Jun 2022 23:22:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3815844D3; Wed, 15 Jun 2022 15:21: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="4VgvCgWx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55FDF844B3; Wed, 15 Jun 2022 15:21: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-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (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 D75EA844A7 for ; Wed, 15 Jun 2022 15:21: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-x62b.google.com with SMTP id o7so23219347eja.1 for ; Wed, 15 Jun 2022 06:21: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=1PSFw/GXIunUH9AyDLtTr1daRQcTtBjiK6dcDxt5n/M=; b=4VgvCgWxLP83jAGTBIhqilze7TdVPjE4oRNrMyBn/NwWkSpYW8aK/KT5u7WIzHkkxM 2gcrKVphmwPsBnotaaHT6a/Vgmh5mA2u6w8BuAVh6a49uIjjRoyN2SJUdrJh1yjyD/OE YqMDannndo95V3GEt19OZIUizM61Lfi62LvfsU2Xg7m8qEmPdEoSwgkaQIsvZSOHssIN 5DpgUvdu3lFn8Z/AFAqNiNXPIcnK8aSOw525SrKMA63e2HQCCp959uxG7/xnof4Vq+Ja 2zvnPIRozdhF86QwgM0qqOt7B9zHA1z7SflCAnAwopuGyCxECoS+y9S3dVyNasKDieeO PnRA== 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=keo0u6uChYkQOFOkxQBc1V+wpA6+quy2eIXWacKvwydwECLAEEYKY6x3/5hQO6AbFK X8rAjo1d6LZK9GOJw1Y/eUdD+pHohspY3CcA92ONEmadphQgiQQpVvwjKUOStJaRvf90 9P/MStF/3GbDNSnaDD3FYmrk6i4/BQzzbq0KDqAG1bbzI1bWLUbzsHilvZYtQPeuJgPU md5apAn8AtVf6t0YxYjNHWvT55l22FBsgEFTeV592vR/zLk9kktA8qaR4ywPCnkSvujX ZxRN0KoDwo3V/U/Ouy1GKGop7xuesAkrhM7RGjR9/WcwYZIEabHpAwUDgsP5Aas7WVge wyGg== X-Gm-Message-State: AOAM532u01lWqqv5O77NgjLWzKnJSYz5pU4bUcImGHJaiA2FtlrP2hCu U1BoTgK8foG8QLgPUArH/12c2EeI5SoSdg== X-Google-Smtp-Source: ABdhPJxglFAxTT2rwuscch5KLbLWXpr8/SgRw8yCsYNn/7xAwXqRnbxdXe7HcprGoVbPneSv6xkamA== X-Received: by 2002:a17:906:7a5e:b0:6fe:d93d:21a3 with SMTP id i30-20020a1709067a5e00b006fed93d21a3mr8914805ejo.596.1655299295212; Wed, 15 Jun 2022 06:21:35 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id l22-20020aa7c316000000b00431962fe5d4sm9302724edq.77.2022.06.15.06.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21: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 v4 06/23] microblaze: Fix stack protection behavior Date: Wed, 15 Jun 2022 15:21:02 +0200 Message-Id: <86b9748bad12142659804d6381bc6bbf20be44f1.1655299267.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 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 13:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643751 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=P3Nkp441; 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 4LNQwK4GVGz9tlf for ; Wed, 15 Jun 2022 23:22:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 57072844DD; Wed, 15 Jun 2022 15:21:47 +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="P3Nkp441"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1422D844C8; Wed, 15 Jun 2022 15:21: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-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 85A2384478 for ; Wed, 15 Jun 2022 15:21: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-ej1-x629.google.com with SMTP id s12so23224268ejx.3 for ; Wed, 15 Jun 2022 06:21: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=sHV87L8jXqk1shojKH0Ccz07k3au65rkzfIVZt/PeJ0=; b=P3Nkp4413OsUEbN8L1q0YvAtnfpxWsT9kSoMMUnjDR4pnWP+qXmvGh8FLZyEgyakZR BFMkkaYhb44qnGC78ffGTbhcOgosk7kTdh1C7Emk14CMOOf3blVBKTlHJbh9fBC9zz/+ dafmarNctvL/wUmoGRhQIj+i4xdlL5kIUdeugdQBfpT28otBU6gQlyX+//4b0EuCwNTT 2Zo1PF9QOwlWcDMd+bZmT9dDGiDOkibcaoA4YPmQertjfNXi/QmkfcvBJ/KD5fVlBjEm 5G0kBbXbpNEZOlGLt9g5PG//Gd0lAeUL/PnTtFngXzMQrMiTqxz/fbzQHOfFXzwGWCGn hrLA== 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=E2dNYsTSOM64UfRQemgFPrkGi6wK63qN2Pe/Nz39hdOO4WscypvWssalgxOpY3oEA7 FAUnyikYOnJXujG10NmhfzcdBlkxP3pcuTHnyJRccSNTIpQYndang+SWOl/VZFEhTkFz lEXeM9mkNfNstmh+9wpYYc+fGXNbheEYKf+C/jRTmvFweg10zeTm5ueNelKjlX5GTrJ6 Ou35EqFVkKc1Eb10Dc9/+Rf7Le5UIi4VYv1lF5a/zPeDdJv4mQpLmiZSvTamFnOTTVxS 8nr2crq8QNHlaguiEsC66vp6fvAbM6Eug1O3M3iM6drTVSkzmyM3XQUsCtfr9vUhnUvx tidQ== X-Gm-Message-State: AJIora/hrNiO2mfIVruyMCEMYfGDSq+5kDeMrJNEEdMw5OLbJCwfeQF7 coB74XhgJ1zNUBfbifnwJTg48710StuS1A== X-Google-Smtp-Source: ABdhPJz80RmmqxDGZlwG67ew9k4oPz7nwqxvp2oSMtJXwzYnJbeCF0+RtxgYfmHZvxy/sAIodCq0Zw== X-Received: by 2002:a17:907:7b86:b0:711:d2c8:ab18 with SMTP id ne6-20020a1709077b8600b00711d2c8ab18mr8808170ejc.580.1655299296829; Wed, 15 Jun 2022 06:21:36 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id z22-20020a50e696000000b0042e032164a4sm9577706edm.61.2022.06.15.06.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21: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 v4 07/23] microblaze: Fix early stack allocation Date: Wed, 15 Jun 2022 15:21:03 +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 13:21:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643752 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=jp2YOHB7; 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 4LNQwX5b9Bz9tlf for ; Wed, 15 Jun 2022 23:23:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDE1A844DA; Wed, 15 Jun 2022 15:21:50 +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="jp2YOHB7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1324844B8; Wed, 15 Jun 2022 15:21:42 +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 565AA844BF for ; Wed, 15 Jun 2022 15:21: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-ej1-x634.google.com with SMTP id h23so23169435ejj.12 for ; Wed, 15 Jun 2022 06:21: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=RHRnHBraUTYxVgQO6N6wdoEAUEjdiTUD5h35kL+Taf0=; b=jp2YOHB78N2scCA7034CTtvWOqILJzIj9DO61/orHVPx4c2PnAjbvZw7tuj45bOMbW Hj/uW+TrKlrVzi9Pf8eDLz7+cnmgDKKxtI+byVnyXzx83OkgbslOpn7hpiiQXCx9+jrk UvHMdYNo2oChlvsRin/CSKHdk0/1HrHqJGeydH3vW+wz7t46qHiAkRBD7rz7hsKhsUBY SVXikzr7kITpCH+D6WeyIhUkNFNIn5VCA0uZHOLY4Ef1Zd8flEpl2gf4CvZnJ4I4r+eJ tC6nrHsVmNuELnV61D0L9jcTTTfcWLYT1fOtRQl2N4OqjxqJJaM6xgI0R4I5GyF3nEaz rn3w== 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=gc5BB+dU3126Vk6uixb6qzNcfg1SxPzWem/z61xAoR21yYRFBa0EzTdNyspGiSQk6b iNasktgN3dQCzkO1OJUvkBjc2WFhQZw1yNiwK0ex2OPU/rkyFKeNXEOqNSStn6+/9gDz 3EqWsJ6CLYJ4p6PXi3GEs3Y34gamUAx63Ni7ILpNzhBCu8rFd3ejFHSMt2ZUCkgyfQHm XMTBXKQCLjyXgicRoh6DWHfD/EHnP/aUIWPMetp7cunhAqGnqmavDABVOfcooCNfvWdM SBgrE2RI8rp/cwSzk5PqscUbQyld5jjUBmQEBqAjgrWws1GUwdjE72moSdRgA6Srp1+y pnKQ== X-Gm-Message-State: AJIora8WHl0ZpsXkomefJXODaotbE+2IulDFYIO1gz2kyc0dojQbh6bu 2HkkDlWmkZMspNcII/JfgKbSVMewLCkZ7g== X-Google-Smtp-Source: ABdhPJxCFCZCbYTWcDnxGfmCe8MmoK+PLb/f6HnmdKoKs7bV27QWwVMa2RXVQ8Uuvv+hk604paSXIQ== X-Received: by 2002:a17:906:6bc6:b0:711:ce74:d09 with SMTP id t6-20020a1709066bc600b00711ce740d09mr9014645ejs.272.1655299298502; Wed, 15 Jun 2022 06:21:38 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id q8-20020a056402518800b0042dd022787esm9520719edd.6.2022.06.15.06.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:38 -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 v4 08/23] microblaze: Remove CONFIG_TEXT_BASE from code Date: Wed, 15 Jun 2022 15:21:04 +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 13:21:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643753 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=y6LkZ57g; 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 4LNQwm4jVLz9tlf for ; Wed, 15 Jun 2022 23:23:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5DC5844FB; Wed, 15 Jun 2022 15:21:52 +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="y6LkZ57g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1DAEC844B9; Wed, 15 Jun 2022 15:21: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-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BD6F68448C for ; Wed, 15 Jun 2022 15:21:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52a.google.com with SMTP id g7so16125425eda.3 for ; Wed, 15 Jun 2022 06:21:40 -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=y6LkZ57gER67w998A4w8l0zZ72VX4mPzw1ex4istrJDuMzcbQKXeFx1Nz1NSU4WYKU D/Uf7B4CXPLiQ8JgICqNoLRC+dOSXYBq/uBynJelW3Q4CzGAuKLCQ1c3WftDFdJjK3c/ diySDGpMmLWvMxuvEMztiAIQIBu8FYZ3ds+0P3eIh9xzWbkQlfzamI5IkWT47D+PkWJo s6993jJ2+NjQaRdayLsK46/c/zJT/oxJbQPiaqyPQUqwHLBQeT7ekieyinxAKHhrbVay SRWgCsZ5bfp2PBRnxLdaWvYfHva8PGFkzeF9aXwZ+O2OYNFXT6tBq7/RH/HRzd3EBYs3 +yBw== 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=wR0/nir+gYPsBdPMP9S2fsppGXwJ0XEGiW1udBHkmtSSBYpAvtaViBczMWgaK5itoR /zQyFnsOu6d23krGFc1x0jGa2t65l7sisTuJrhOArTAgi1PiAQMDo5ZBsJ81ecfKW9bU o2hD/BzToWnAkQieCnVeQCnYc5LyuZZ41hvHLqPEwfNFkEH6XoSKSSiI0cmn5PAI4RP1 Wjg/SSYX/0bx+UJ8Wx+ozRzMHdamkxx0rcDf6ao5wdKR5Dwd0/7cUy1YfK+ypXd1I8xI t40Fw7LvaVUuQNDDKZ3tObPJ8+uPcMLYjH+LfwWK9Btuas2B3s0NJqvn42IkYvpxCby4 r1ng== X-Gm-Message-State: AJIora/VfkxZLM1XKHq9M7wLyPMlg6VYbWdLUo/egsc4CRssKm009Qlh vcLv/5wGeEt2H3bw9AP2K1g8Qz/9Kd8EAw== X-Google-Smtp-Source: ABdhPJykIiGjFbcMi0cwuviMvek47wcSQFks9XVrgxux2RYO1MZ+DImM2/Ppkjdb0si7uEQh8TNCNA== X-Received: by 2002:a05:6402:438a:b0:42e:985:4944 with SMTP id o10-20020a056402438a00b0042e09854944mr12680005edc.283.1655299300087; Wed, 15 Jun 2022 06:21:40 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id z22-20020a50e696000000b0042e032164a4sm9577809edm.61.2022.06.15.06.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:39 -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 v4 09/23] microblaze: Fix typo in exception.c Date: Wed, 15 Jun 2022 15:21:05 +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 13:21:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643754 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=Q91tZJHT; 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 4LNQwz0jSBz9tlf for ; Wed, 15 Jun 2022 23:23:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D30A4844F3; Wed, 15 Jun 2022 15:21:54 +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="Q91tZJHT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6961844D3; Wed, 15 Jun 2022 15:21:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 60DC5844A9 for ; Wed, 15 Jun 2022 15:21:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52a.google.com with SMTP id v19so16135888edd.4 for ; Wed, 15 Jun 2022 06:21:42 -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=+90R9T/3G6o9cwWGgZh9DwDEiAxJ40z7kcoNHEJfXeg=; b=Q91tZJHT+67UWpLKWfHzklgzWcG6FIV7bAnf30xwOsggsAokQK72OM8ZIujMs7zLZd w4c0+hciIDtuhEnZl19+SGJfeBZlUma+IoEw97XPKu0sr/ez8EWzcmAM7PJrOWGhN7LZ PQgNVplWI3sE2gO9Df72TtQkMEFahiqPHryQYPQUHy0Ys+6aTent9wnWRu3TESx4FIr0 dCU3Yp6LrRgERqLRfwSM+99XXohWZPDWEpJJv8GK9Bg2J8oFgAYyNh9hFtE1rLTtyhVW eNPqKXTO6jWb2Jn9+RPXwRToTSWQ4IHY0Wu8psBqDFUSTTo7Z6uoF/5O1GODks/7w0FV gSlQ== 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=+90R9T/3G6o9cwWGgZh9DwDEiAxJ40z7kcoNHEJfXeg=; b=BgOr/DGk8M1dacgtYJrDHDXmXsrK3MxWdK5ECAuaEF7KS34otBbdoN+2WVe59U59sm jatgqO1C0vNd3xb/Lfu4DlnO2LmeC6+m1aPJ1gznhwAw4j36tWqOHFy+k8oX0BhJvavU lPRNEHu05iUdymAQRqc9vrKCLgHRwMYkQuDQDUQcz7MgZaImeL/adt/Wpt/NeJvHr1zQ f9s4z5SEivGCpECgFITX7MiqQGKhDf4zLLSyD3dsyqmPOJ6YpBjOVVrIffRQScqe2+B5 4w3M85qW5vqGCYVFKYzuqiTv2xlL9a06mbjwapykXhYnMJDZTAp2O8wTWNihZlrWIYa6 deBQ== X-Gm-Message-State: AJIora/LtEu8U+yBKkhJZ3BBpUThqaMdgKSh87H/itXKd5bUEJvtEysn qvO+qWMJa+NcihgOk6dNpTAY/hKM3pl2rg== X-Google-Smtp-Source: ABdhPJxbQBgjrht5YsECWCqHZd10NUqEaUnwAQs5Esw8gk24PkI8E/rIl/0rm63zZyAFUr++OmvpRA== X-Received: by 2002:a05:6402:322a:b0:42e:1778:1f1f with SMTP id g42-20020a056402322a00b0042e17781f1fmr12942265eda.115.1655299301706; Wed, 15 Jun 2022 06:21:41 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id g3-20020a056402424300b0042bd75c53casm9588845edb.83.2022.06.15.06.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:41 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Daniel Schwierzeck , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v4 10/23] mips: Move endianness selection to arch/Kconfig Date: Wed, 15 Jun 2022 15:21:06 +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 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 v4: - Revert incorrect m68k merge - wrong patch 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 | 22 ++++++++++++++++++++++ arch/mips/Kconfig | 18 ------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 12de8a11650d..4851300e9bbe 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -447,3 +447,25 @@ source "arch/xtensa/Kconfig" source "arch/riscv/Kconfig" source "board/keymile/Kconfig" + +if MIPS + +choice + prompt "Endianness selection" + help + Some MIPS boards can be configured for either little or big endian + byte order. These modes require different U-Boot images. In general there + is one preferred byteorder for a particular system but some systems are + just as commonly used in the one or the other endianness. + +config SYS_BIG_ENDIAN + bool "Big endian" + depends on SUPPORTS_BIG_ENDIAN + +config SYS_LITTLE_ENDIAN + bool "Little endian" + depends on SUPPORTS_LITTLE_ENDIAN + +endchoice + +endif diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9b62764f4fe6..2e0793a7a7b8 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -180,24 +180,6 @@ source "arch/mips/mach-octeon/Kconfig" if MIPS -choice - prompt "Endianness selection" - help - Some MIPS boards can be configured for either little or big endian - byte order. These modes require different U-Boot images. In general there - is one preferred byteorder for a particular system but some systems are - just as commonly used in the one or the other endianness. - -config SYS_BIG_ENDIAN - bool "Big endian" - depends on SUPPORTS_BIG_ENDIAN - -config SYS_LITTLE_ENDIAN - bool "Little endian" - depends on SUPPORTS_LITTLE_ENDIAN - -endchoice - choice prompt "CPU selection" default CPU_MIPS32_R2 From patchwork Wed Jun 15 13:21:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643755 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=FTaLJyac; 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 4LNQx917Rwz9tlf for ; Wed, 15 Jun 2022 23:23:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 98C5A844E9; Wed, 15 Jun 2022 15:21: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="FTaLJyac"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82742844D8; Wed, 15 Jun 2022 15:21: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-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (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 2AC57844BF for ; Wed, 15 Jun 2022 15:21:44 +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-x62b.google.com with SMTP id gl15so23212966ejb.4 for ; Wed, 15 Jun 2022 06:21:44 -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=lT9pkI+MRQ8liiNWPW7P4ydX9cyyA6vABPpGsK2JKmI=; b=FTaLJyacXR0BK5febimixJ5AXZgcNm1cxjZQh5MDvavad9z7+URBvUdMonhWG61Lcm pg//KJ7GdeFzij/S/OH3jDz9VgbuPVwtYH15HH+ydBrzrKvWWAka25GFaA3bWnVWstB8 8QzVabLbrWrutIowYtigXq6qfDweo9FjP5Xz+8fsFLE4tK35NrPZ4NeTUKfMCEHa4qyo EeKNa2jPfxbPlgNzxFaddSGXcwvKXQiWKiADAG0feCxRQ7p0Jzh1Q7+mOevaDLXOOCIt NP8a1CKSrL7vYeix6Vl0qct0cfSmsK9ojUf+0L6dB0FovWGSWRsrh2/KDzfdbO1z2dD7 cyVA== 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=lT9pkI+MRQ8liiNWPW7P4ydX9cyyA6vABPpGsK2JKmI=; b=HFr296wjLssfV4XsWF9cMAPeTD8E5+9OckRIvvtiGFrJejmp9fieJwzKN7d2E3JN/i fQZfSUJaVeYebddJXPJcYm/83G2Bngy3sdpDm0u48CNCJJWNm/IoyKpWOlr0bGCLJB8i 8vS8Ae0k//SBcRhG22u6vZNjYNTdUGp9VVLig2xWADFvHzmYii/itFP3WWAse6y7yNgT AwcFCunKAUxRT7pySpi0rDNjYyMAHIngEsw7cTI4ZzjgxQdokyrzRgcfRgomPWjYtLjQ dyaGE6HfGVtLBRZK9Z1vpd5cgK2onmnYb+uG2Zfi6d49hTLjxujI46Yv0LKV3AEy8e+h xI7A== X-Gm-Message-State: AJIora9m3TBKIk4W9Qv+3smWsVF2eiNOU332oaGmK2oURasStIHAUjz8 Kqe8zlOwYTARTKuhKzWd7g4GB9ETLKAlmw== X-Google-Smtp-Source: AGRyM1sIrAQLhNfzLX/mpzblL7qqR8huQeRGUhwZTtF+R62GvodvjsGMOdL1hpI9U6LTvwGdKfumag== X-Received: by 2002:a17:906:610:b0:715:79ac:7db9 with SMTP id s16-20020a170906061000b0071579ac7db9mr8826707ejb.226.1655299303379; Wed, 15 Jun 2022 06:21:43 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id j10-20020a50d00a000000b004319b12371asm9481370edf.47.2022.06.15.06.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:42 -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 v4 11/23] microblaze: Enable REMAKE_ELF Date: Wed, 15 Jun 2022 15:21:07 +0200 Message-Id: <7e242a519fcd1c693b9103c5599b515af555ca43.1655299267.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 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 4851300e9bbe..02de32f9c77f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -448,7 +448,7 @@ source "arch/riscv/Kconfig" source "board/keymile/Kconfig" -if MIPS +if MIPS || MICROBLAZE choice prompt "Endianness selection" @@ -460,11 +460,11 @@ choice config SYS_BIG_ENDIAN bool "Big endian" - depends on SUPPORTS_BIG_ENDIAN + depends on (SUPPORTS_BIG_ENDIAN && MIPS) || MICROBLAZE config SYS_LITTLE_ENDIAN bool "Little endian" - depends on SUPPORTS_LITTLE_ENDIAN + depends on (SUPPORTS_LITTLE_ENDIAN && MIPS) || MICROBLAZE endchoice diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index de5b97e719cc..3e84a832fc12 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -16,3 +16,9 @@ LDFLAGS_FINAL += --gc-sections ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC endif + +ifeq ($(CONFIG_SYS_LITTLE_ENDIAN),y) +PLATFORM_ELFFLAGS += -B microblaze $(OBJCOPYFLAGS) -O elf32-microblazeel +else +PLATFORM_ELFFLAGS += -B microblaze $(OBJCOPYFLAGS) -O elf32-microblaze +endif diff --git a/configs/microblaze-generic_defconfig b/configs/microblaze-generic_defconfig index 7994110b28a7..35e32466bdff 100644 --- a/configs/microblaze-generic_defconfig +++ b/configs/microblaze-generic_defconfig @@ -14,6 +14,7 @@ CONFIG_XILINX_MICROBLAZE0_USE_BARREL=1 CONFIG_XILINX_MICROBLAZE0_USE_DIV=1 CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=1 CONFIG_DISTRO_DEFAULTS=y +CONFIG_REMAKE_ELF=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_BOOTDELAY=-1 From patchwork Wed Jun 15 13:21:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643756 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=h5PKDgWy; 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 4LNQxN2dX6z9tlf for ; Wed, 15 Jun 2022 23:23:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73C9E84508; Wed, 15 Jun 2022 15:21: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="h5PKDgWy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D012A844E0; Wed, 15 Jun 2022 15:21:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AA879844D2 for ; Wed, 15 Jun 2022 15:21: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-x52e.google.com with SMTP id b8so16086929edj.11 for ; Wed, 15 Jun 2022 06:21: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=RyAF2xd4Hb4C8EpLjwqmXNodZhPy1T6CU0Ah81MTlxE=; b=h5PKDgWy1KRSaKDj4KFjr/3oBck13V9SNlIoIX0Yj+e6TTNNqqbm7iZK8qMcRsL7iV R53mOPBv3MzcLhO9bWHmM4547j47IdZ2AHczQopWZ+MySXI/uVqyGLH34h0zSUv8MnHJ /GKJ6jZzoSHZNLuu691txFcVd7yWzbQ8G3DNS/tUBRwslFz6N7wWldZCmwNhsL1AyXtg EqW+Nv7kOTuzTb3i2cvU+ek4SJWjVpycBuLTMtyFZxkGovvmze/DV2SxHOeaC3w0vtN2 j30CAqvz7TJak2jUZ4ZRn3hdODFPNvh4agcPgBtp8zqBVsWWUQB29IhqPg+zVYN+w+MF M9kg== 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=Pe8MTxRQPDiDspEQqX+vDtar2dbs0U5auvXxGpPltIETeHXb6/BFE+owO61XbeP7ae HnQZzgVLtbpBiGEqmMOIkKXYOiJWEMzP6LuWyj86ltaX9cVfGgsv/1PSPLMdib+25NSc 6JCQCbo8KEVnZEF3r7uj7ovpgIGxznNaEl3038PVpzhR3PvPrrKNMAd5O/dWy6pie82n 24k1A8SuvUhU789aGEpC2vA11YtqDiwprKBLtnKJspfUGFT3Vy5p7oo5Nu2FfUUcM1/5 R97IkHKRjKkadxgM6oq/s7ms9OX42Y7OZk9Ldid0hjKNEOU8W0mEqsg6K2ApBtybJ9NX 6LpA== X-Gm-Message-State: AJIora/GK/f5Uk3YXoF3okHV9vJNdcDtlwn6comQMbEXlCEyKya94W7t 1JGRTUq/3Q7uBa0wXmPZefIPtzqnbVBaSw== X-Google-Smtp-Source: AGRyM1tnaA54Wn2mpu4bw3c++aFnmImxHJXnBVOUPbwd6lRtoP6ZsW5kx5cQT96Ph0HptSdCb8MVZQ== X-Received: by 2002:a05:6402:5008:b0:42d:c421:48c8 with SMTP id p8-20020a056402500800b0042dc42148c8mr12844233eda.422.1655299305022; Wed, 15 Jun 2022 06:21:45 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id i3-20020a170906a28300b0070b8a467c82sm6328898ejz.22.2022.06.15.06.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:44 -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 v4 12/23] microblaze: Separate code end substraction Date: Wed, 15 Jun 2022 15:21:08 +0200 Message-Id: <030863fa9a9c1ca0a9b082fe498522da09189fbc.1655299267.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 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 13:21:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643757 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=elFUFdxj; 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 4LNQxZ6cg9z9tlf for ; Wed, 15 Jun 2022 23:24:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C902B844FC; Wed, 15 Jun 2022 15:22: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="elFUFdxj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CC6D844E7; Wed, 15 Jun 2022 15:21:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 30E71844D8 for ; Wed, 15 Jun 2022 15:21: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-ej1-x629.google.com with SMTP id s12so23224268ejx.3 for ; Wed, 15 Jun 2022 06:21: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=sSOfhCDzYe8wwhwsc8DY160ixzidP+0QfnDEEWhouJI=; b=elFUFdxjOxtUnuJOUgDSkebieQ53ytOQZucuhaJxnM5VT2PTTigDlMUxTjb9ydqbCU fWhzPOfnuQHOa6p/53Qme5Dtsf78lLMmZ1Pz7cCwtZ7qYKIbwJDG/uQJsmYi1GHJUpvj Q1dlp3Y+l8XMfPWgDIodsW6NcI4p+tmV1pDTt/ZTxMUz18dct76iHmv+XjFWPkJAyc2U eqq/d5a0d5upPptX0pT1GvZzDuHmKKhYUPaAUD5KcWY1KYrmWwaaa7tBQuUo3gYDHfQd Jv+SpnVFGQyRfF28LH8AJuJk1KxMp4aj8liX4CWGWJRJYbrp/9IwkehICpCPL83acOzj trJg== 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=3S55gUhdwNdDoo/BHZHUW7zinGduzzZHuSaWEvzdW7zqy/7Zo63x1bj339BFv1fEa6 a0afITtOT3JD9n0im6z0YDcLxs/puonSQucquTEDvczgg7R6vx+9NHj3R8xH5UebgYrW 4qOlpM8xOazxUHtqL6fd2tfsJcapYJ+djckVbvAVLAJGCobTSUEAckF6FHp5iNfNpmH8 Rm/tQZuHCKNjrcnTTzd/Pq1iBRisGbGGtClrc73RVinbKb68UK9TIXHfbTQNIQLWZKKV 91qwQXbQlXcdXhaCV6G64anGk3ir7xbo2cjSJwVM/W8pQ12InHn6tf6CsYIWzDqyo7DF M0HA== X-Gm-Message-State: AOAM53345nz+VlIxGiEdwFir53+d1kW4PKFauIWlKKpby4x4jYHrXlHk vV1Gj8IfBn+GKQPMgWDb4eR6Rz0C90NCNA== X-Google-Smtp-Source: AGRyM1vLUpn2EUcEb4dXEritjkM1LyylKla5qpRdLEF/MmX/1wlq1SZwTkUfbYJfR6L3N2Ag62M8Sg== X-Received: by 2002:a17:907:2d2a:b0:710:76a1:4d89 with SMTP id gs42-20020a1709072d2a00b0071076a14d89mr8826062ejc.307.1655299306672; Wed, 15 Jun 2022 06:21:46 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id cm20-20020a0564020c9400b004316f94ec4esm9247036edb.66.2022.06.15.06.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:46 -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 v4 13/23] microblaze: Change stack protection address to new stack address Date: Wed, 15 Jun 2022 15:21:09 +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 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 13:21:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643758 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=DdlnNpCi; 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 4LNQxn2CK6z9tlf for ; Wed, 15 Jun 2022 23:24:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9642984510; Wed, 15 Jun 2022 15:22:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="DdlnNpCi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9BE7844F1; Wed, 15 Jun 2022 15:21: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=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 02BC0844D2 for ; Wed, 15 Jun 2022 15:21:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x632.google.com with SMTP id m20so23162005ejj.10 for ; Wed, 15 Jun 2022 06:21:48 -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=DdlnNpCiHvD+pZC/I+70Bc435PV9rjUNRhhU5syo/DFJiEgjZxMFQalgOt6971dEYK jCTe3B6Lp1ysMYKH+o4rCVG9HGsjhqN5HzSSGfwm2FTz11JP98k9uDGB3nJdwGHj0Ohx f4l029vA876sIhGAAXyhjYdGsHelK5rgOKjJhrgvUWIrNzlrty0CafwODtYNoPuqLISf FpACaX+5s7T3eyjR9dFWWKt7z2xsEP/+eQkYRGEQNJjYN+yO/n8HYVK2RxqYlDZn5rrM Z8R9v57Kh7cY3ottwfqN9INJmmBDENNFev7/KN5mRWVT5s95yihLsbhK4puEome4YgQQ BjPw== 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=7TJ3eIVZWj3ya4Suat6Y3GkW0tVR+k4CWWGKdblnhVlPvuc6j1Voqw9CuAoZJ9YCpu xKGoFfO2Np9bGxVv1cneaSqQ7gn0/qPHAmlLY/d4BdnEdt4yjQtETU6He9WZNs+p220c gaDJTYE/bn3c3ewQU8AsBmHilVvbsebUQPnTButS6aCx28pmJTDvoc0Uvd3gylr0Hyot B7+Fdc6fURuOcOsVwx3Sq1dxsKAWehXkqQWDe5Rzf58ddra3I2qTdldIy4NkslD3lQFl +Rj06ZBxkVJox9x+CslpZD/DlXFkz0dbm+HpxhaltsNYts1bwhmHjPtBhMxr3LXH/mrV kh7g== X-Gm-Message-State: AOAM5331INGjVhc3NwAbqpgXughrcakgqmUwSzFdzREVpLHq4upinpuz d9Js9dqLUmj6Vyt+22VRxiYkWiI5ZGdG/w== X-Google-Smtp-Source: AGRyM1tLdvr55awOKLyU33+6B+q60IX14DTvq5dckyECJ0IeqpvcwPsY4PWjjlgwIkla213/0Vd1IQ== X-Received: by 2002:a17:906:c10:b0:6f4:6c70:b00f with SMTP id s16-20020a1709060c1000b006f46c70b00fmr8841499ejf.660.1655299308235; Wed, 15 Jun 2022 06:21:48 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id h8-20020a1709060f4800b0070a50832376sm6242193ejj.154.2022.06.15.06.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:47 -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 v4 14/23] microblaze: Optimize register usage in relocate_code Date: Wed, 15 Jun 2022 15:21:10 +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 13:21:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643759 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=GVuSk/a2; 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 4LNQxz4WHXz9tlf for ; Wed, 15 Jun 2022 23:24:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CED284522; Wed, 15 Jun 2022 15:22: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="GVuSk/a2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C2A9844FF; Wed, 15 Jun 2022 15:21:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-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 C788E844E7 for ; Wed, 15 Jun 2022 15:21:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x536.google.com with SMTP id w27so16111400edl.7 for ; Wed, 15 Jun 2022 06:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/1f9n0nd7OMxqcDbecyk8IQlRj7O/M19gnjS+/3QcqQ=; b=GVuSk/a294swNwNk+05c6hF/EfpQAuBLDEbM+/3YpbTcayImkS6tk+9pyDC0HALu4b 9flTR7AWCdyNvEjOhoBxkSVFuPNKmD0XkTbFD1CcAF8VHNy2FtMIDJozdImRCNrKrKvU rEewwdCXdrizsaeSC+hvXZjQeDDaL+JZMBzklNhyy1tOCU99cSwo/kv3FyA0bv2dEXPp pGFSCD3MMKuH/20I0gDcWQnS2lHS7BOqFjNETD9MqFA03MPclNC1CQeRK8L3gHwK7RyK h+EVSKSXTo6ePikDXKCslP6G3tBr2tHlAenkSFAhvWYdhCcPYbNtyRJvlbYyfmBlVXBa Vn3w== 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=ZAVcGaiLWg5uGuRGeVB7FAeKtnxN49gUjokzzxCtJNfwo22liPzCnr22PJPh10BzYb Ffw1Xd/G+I6ppHb+aT/YkDl8dQ5t9fEsHSCyO4JVA8xvtROnSGiq2aGzCMzLegHHGDHG rGma524X+Zb9B9xohLfmdg+rPtnpamKVzZs8bOBKjFgRcQZBLt96QPoX7/HWpL9DjqFT XiaVnj18mLq0FZTI9pjyxKQM/Vpw6XCCpCZgFRUPp5F7neWZG1OjQPRTdwAmuZU7li6F Ar/Pz/2v/PJSQh6Bn8wXWg0b4eAgGGLgvrbcVIzA2fVtBG9fWQqCLFnZi4zWuf9T0Mlt PXiA== X-Gm-Message-State: AOAM531OiZV5hcLUsmi8t0gwAgq+vc1VmMJtH5nEHWgU/OHbqc8q81ne KTaiil8EPsOu4OX8YTDSSIrnsXIuFLrB2A== X-Google-Smtp-Source: ABdhPJyBkHXMcQPzjdWKFrSKUZpQFk9Q8XvWuYtLny17V3FMRqIGIfqvwx2ZyiixghvKxgrzurl3oA== X-Received: by 2002:a05:6402:330:b0:42d:cd47:89f3 with SMTP id q16-20020a056402033000b0042dcd4789f3mr12598410edw.301.1655299310096; Wed, 15 Jun 2022 06:21:50 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id le6-20020a170907170600b0070e1adff390sm6293237ejc.34.2022.06.15.06.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:49 -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 v4 15/23] microblaze: Remove code around r20 in relocate_code() Date: Wed, 15 Jun 2022 15:21:11 +0200 Message-Id: <1b32bab5c050d099b2f6d49bc4896322ed03d788.1655299267.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 13:21:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643760 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=Wj1Rr7GS; 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 4LNQy96Xvyz9tlf for ; Wed, 15 Jun 2022 23:24:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C811784511; Wed, 15 Jun 2022 15:22: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="Wj1Rr7GS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10607844D2; Wed, 15 Jun 2022 15:21:55 +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 997D3844F1 for ; Wed, 15 Jun 2022 15:21:52 +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 n28so16121190edb.9 for ; Wed, 15 Jun 2022 06:21:52 -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=Wj1Rr7GSrfIGGSKnEY5g03bZcLbvYlKC9rxV8paoiQk7MJdyttX9RkSJa3rGZb+P6w ioM1yxPbXFesQoevRA65NIhaSrAPb3rYWJz3HlXox1WpkVL8afTnOo320mnKhEYji0IR 4hBQh+099QpgpKlLyU2Wof7t+1nwoA4P6XZcbALbhDnSr0C9vjoS4Dj7sb07JEa7r5kZ heZ+IVgQJNcvo2hKP0eSH6+nJ6I6lDZ92j0YMm5AtdeiaV56cR0PR5rLxgw8A5aPBF5p BW+GZ+98ZzstnzWOgSIfYWuC371P+/kpRxwueIHEuTzA2m6JcbOSr0QYKp76qjKXtP1R ZsUw== 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=Kp8VZNWBbXEPC4/jGJ4RDqYKz8hAbj7U/gulxDwa5QE7rhSZ8R58om+iLRskCFC1Vg RDPXmIhvDe0g8O2FgxzFtbW3HQkA2MNDnTJsMtgGiwfRd/XtznAvxSHQJxbE/+FRevex PbtaPPP3crTHVd5skJvMxj4gSYGQBQ949K/jwhwIgyrZ9PhHbEANOF1KZCWSJ0vgFsVn 2NhlHKGRt00qEt14dFQ1l6YTUQCrmQZwG1ec87dBfaMkcHUbVYS1Sxqvqgf7m18Asnay fpETZH+EDjVlLcw0Oh0q4k5M/mrGVygGMZmJxQeVRb5Q1F8Ztzp1qWOt6gs5X8utzt59 bG0Q== X-Gm-Message-State: AJIora/mASaCIPN8mCx7MJMR9DnOC+qUB1aVecwuAtr6nPpMUDbnKNrP Ki5iHHyNh42Nka6gYgh8Qp5GNTEB7YfOJw== X-Google-Smtp-Source: ABdhPJw/d4+qCpa9kzKLTOxCZUHY9pH2ifoYBjIzmSvlA4v4+zqZeF0SSe+yr1PDZJeUyVblkRGbfA== X-Received: by 2002:a05:6402:1e8b:b0:41c:59f6:2c26 with SMTP id f11-20020a0564021e8b00b0041c59f62c26mr12952077edf.156.1655299311682; Wed, 15 Jun 2022 06:21:51 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id en11-20020a056402528b00b004315f96fd24sm9205515edb.31.2022.06.15.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:51 -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 v4 16/23] microblaze: Remove _start symbol handling at U-Boot start Date: Wed, 15 Jun 2022 15:21:12 +0200 Message-Id: <044b727c33dfbe662f68512d0da0775a4805f360.1655299267.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 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 13:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643761 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=tghzPB8g; 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 4LNQyM3y2gz9tlf for ; Wed, 15 Jun 2022 23:24:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72FAE8451D; Wed, 15 Jun 2022 15:22: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="tghzPB8g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D75184501; Wed, 15 Jun 2022 15:21:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 E40FA844E7 for ; Wed, 15 Jun 2022 15:21:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x536.google.com with SMTP id w27so16111400edl.7 for ; Wed, 15 Jun 2022 06:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HHn5YZe9TJxpReTWRnM+mdVX0gVPBjQ/hegbrYYrLTk=; b=tghzPB8gZaKvxVqPvzFqD30WHPGQ08hlBJc586/KXysTwN4AIyQo0LqH218PvZz8kn HAKB/0TEFGx0W0HTmFu2ebiKKqzPGP7w1gFuhAEq7cYWXgI+hTXAZfQHi1QP80X4Bu1/ jhDrpNxGkbzmPRK6MLGNR4AybRZFAFaRqXDnvx6W+QuJTWIgKbMS1bY1qTUgl/ei9aQJ NRTXd+qoAPnp0cBF284i/lcwhG9TZJiHkbA1mSb6DZ5NF7Z9dTAe1RZrYBZbvWMHxN5a 4bP1qSTo23xOBbRi0SpNa7ez/3TgO8DYlofrZItCdamaTIV4K/RMjr4OXevUt3UeV5nn /lsA== 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=3idCNsMt/aDNOYSXbUYr5aIXBG6FhDvxCCLmC0YnUdAx8q0NaapE0xfyPKnT7A9ddt y0IeGxTZeujTphXuavT+4e+Mr7rAVscXcakixLQWWFSLfR5aqI0yX9QBbOvIbV2coSf4 X3et1xQP3optvx6TD1CCuYptKXZ0xlu2OFFNb6JRjrw5bYKh0yfJYXahf98RDBLjtb9H UNBv79swSXz0F4OdMaZfgPdRRo5zrEv8E0PJii1b4NA65+eVJGTZWM9AgjwV4WEc6+PX 3tdLTuEvYW8Ua7EwIb2bIRAsBV986cu7REjcPUjLSvcvNVdI+L4m0MxJrif6FzgfSjVG LP4A== X-Gm-Message-State: AJIora/ABWnXupDjOGumxb5hR2YP/rods/XsymxYujWJomkDF8CwkrH9 ING+TPP1lSZJqJsXUe1+JK/uW0AY51yWBg== X-Google-Smtp-Source: ABdhPJw0WQKOwVl01vw3jTeuq718vEiH56Zzg5BbIhxsGCT8UhFFDXgNVncywAzDkW7Fy1MCC6zhYA== X-Received: by 2002:a05:6402:25c2:b0:431:932e:eb6f with SMTP id x2-20020a05640225c200b00431932eeb6fmr12613144edb.296.1655299313406; Wed, 15 Jun 2022 06:21:53 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id fs36-20020a170907602400b00705f6dab05bsm6259499ejc.183.2022.06.15.06.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:52 -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 v4 17/23] microblaze: Add comment about reset location Date: Wed, 15 Jun 2022 15:21:13 +0200 Message-Id: <5ca6341b7487708247fe2948d7e496ea6f7c2e02.1655299267.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 13:21:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643762 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=qEo4eaPS; 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 4LNQyY3YDbz9tlf for ; Wed, 15 Jun 2022 23:24:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C91378450B; Wed, 15 Jun 2022 15:22:17 +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="qEo4eaPS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7758844F1; Wed, 15 Jun 2022 15:21:58 +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 C8A0E844F1 for ; Wed, 15 Jun 2022 15:21:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x530.google.com with SMTP id cn20so3708639edb.6 for ; Wed, 15 Jun 2022 06:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gfxWF+FbAZfqr6AUPukHdvTbCVhWRakSDQbhL27NpwQ=; b=qEo4eaPSnMD/MQpp6BAg8K77ImmbONvO27Tx10QYhVdJ4P58Seh+0xjTm+E9+uQJs5 rLAXlzCZFzjVIdM1rftNRNmUcFFcxog17QtrTNF/GqzZo6TDmRPU+Qt+pnnYxO8LZJ3q TvfktfybA0cGGvTZWWlOShV87RXccw7xisL8aaKJlgpCKbl5nZesLDuEJWa/tapWcPOi grjbW+4RLTDcOrhj9lXbHBqWULhO1AqR7btUKDN1gzdIwGEpaCKuNDjzoyYBbjFi+OyI 3NzNyX4i9WYd5VtWg5Dfw5MLgTkisbrUGahjRzeVtsXzqBEYIh4+x9ijJKGlowoZ716i JiRw== 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=YUOpxKx4Gte5krL6jMaQdVl5XdCQgp8TCCRGYFTAM+y0GU1WkedrpXZLVaRb2fpETr liAGkbtNV6ZJ93ax0S15LEBhMTTXlfWsRYA1OoldkdLqCdV0dcuEsF13me6sxtp8M9uY AywRNEaRLzh8vufnHXJHxkUYk1VcSvSA/Gi93eB7PhNbVFwlAWgRUeYgHuH+P9lnF+HA z17Isc+8X68a4dvlS22F8uUIPGTHdkbjNbbd+M83Dx/RfuzLqJujoKpnI6HdCINDMgBt EqoRYHn2wiGl3at/xhc+NiyDB2AAmhRRP9nsQNpjrlUhTkbu/lkAxqmvdA6KpzLa+jO8 kBuQ== X-Gm-Message-State: AOAM530UBx7YDgPwajRvFOi8yS2Z+KmssxWQecyyIOmy8PrapeLP3VFv oafzMmqp0jXxWlxgFKLgf5ZSXkqAA9GYLg== X-Google-Smtp-Source: ABdhPJzzHM1XtGd0BA1jws+nqDMP+HnNamBGva6TCtFkeRluRrESCaJesmhmOE5cOCaCBoKsdTmphQ== X-Received: by 2002:a50:fe98:0:b0:435:a8b:c4c3 with SMTP id d24-20020a50fe98000000b004350a8bc4c3mr9367871edt.78.1655299315111; Wed, 15 Jun 2022 06:21:55 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id i5-20020a1709061e4500b006ff59151e34sm6347489ejj.39.2022.06.15.06.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:54 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Michal Simek , Ovidiu Panait Subject: [PATCH v4 18/23] microblaze: Create SYM_ADDR macro to deal with symbols Date: Wed, 15 Jun 2022 15:21:14 +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 13:21:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643763 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=hzL4cOdE; 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 4LNQym1gMgz9sPC for ; Wed, 15 Jun 2022 23:25:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B53E8452F; Wed, 15 Jun 2022 15:22:21 +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="hzL4cOdE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B3EF844F1; Wed, 15 Jun 2022 15:22:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-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 9147B844F5 for ; Wed, 15 Jun 2022 15:21:57 +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 fu3so23184579ejc.7 for ; Wed, 15 Jun 2022 06:21:57 -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=hzL4cOdENeneQLm/RAU/LBkR7wdiH3DgDrtSqipk6Idjgcahx82mCm7r6QbbczAyB3 RcZt+Cd71dPspcuD8YtAN70VmpAGY5lczxoIsjl0c52wch60vXSpMBM1q4UUTYtHf/CZ EWaYMmYbtyUMfw26PCrGb3zQitf437IM2FTbKJRtq63ba+br2Zd4VjijjPgt1KjuAppP ifeVvCjU6oq0TYmdWCvHjbVk9DYBGFIbJjz3cpTJNmK5w52dHIgxNdr2PCW58Xr/GNdS iIvzljLfqUshOOTLYV7PYIeCAB4+5f9O0W459hj1Z41DrvsB3fRk9vBjdSs/VFvZWayV HDaA== 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=G8vGJ8Gf0aWJ+ZmwQDNJnk/femaajF18+Llz875tCc9T0qat8qf01dgiq2zHWtf+Jo iRiCeNiJ1dNNwi6vzYITqHvFHOoS1ILDKv3BkLA9nCEsmOHhTbARG+UAUWwmpScQ3oo+ HlLBLIiy+gj/vJU62oBCcTnheogPt5bft0IkV/EZ10BrJB5v6l6VMrVd1GF5WKz4cvL/ Fq8l8+cR5phnT9uQFdLAUGdsW0myjcDMP0qgoetLpp3fGvCyISHgEUuf6oX8JLPzsf+P DTB7ZklrUB1LESaMH1FDfHWjn1AJni5Qp5W3HaPJ8Hf68phhtIIA6yvJpLLEVpE/aoQ8 voeg== X-Gm-Message-State: AOAM530vZPvfll1QHKYcTk9peELsa7AQSo0Io1jZ3H4uEAwrnGOxcVgB AVwa1dYPuDLHh37b/CM3C/9+hRtQ8PqeTA== X-Google-Smtp-Source: ABdhPJxf+3EK3zCuui5m4zkBIcKTCBFLX1YQtTU3qN0oZHOJ2rnDKjG7q664givNH72pUrCp1bMgqQ== X-Received: by 2002:a17:907:6d9b:b0:711:d26b:f5ba with SMTP id sb27-20020a1709076d9b00b00711d26bf5bamr8758280ejc.135.1655299316945; Wed, 15 Jun 2022 06:21:56 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id j3-20020a170906278300b0070587f81bcfsm6421600ejc.19.2022.06.15.06.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:56 -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 v4 19/23] tools: relocate-rela: Extract elf64 reloc to special function Date: Wed, 15 Jun 2022 15:21:15 +0200 Message-Id: <21763b80527521c85ca7d4ac64ad6ff4885409c8.1655299267.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 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 13:21:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643764 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=l1IQeOis; 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 4LNQyy4q8sz9sPC for ; Wed, 15 Jun 2022 23:25:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DF5A84530; Wed, 15 Jun 2022 15:22:23 +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="l1IQeOis"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CDD798450F; Wed, 15 Jun 2022 15:22:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 34440844FF for ; Wed, 15 Jun 2022 15:21:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=monstr.eu Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x52a.google.com with SMTP id v19so16135888edd.4 for ; Wed, 15 Jun 2022 06:21:59 -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=l1IQeOisdTGpWwcWHtd2krBisgJ1Smw462Ra/i4EIaSJrOxtMs1jkfoBadvxJq/uxi JEgaOOiMOsq7CW21pJGXeN0ghEUa7J3iSx600dg+uJhk396GidxsvFwkKDbJPRyESPdL 4TfkVHtzWfTdiKEcwB0ztVOT0/ybeaW8gPRB/6OTkAp/MWU6KDW2gK6mLwbbaU6/FN4d cOjCJFe0HCaI/+O/HKbzYyjdUWG1kQoDXn+C0FPnrl97Hpwekv0uQQ8lgRu2M6y7mh08 P3OfCIrHZL+Q06hRO1uPZ6ofsDwxrUqkdbDlRxFABuH4QGkTKeeyoikmdd0D3Phl5m3N lHHg== 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=RwjzklRc2VloMJbZ6VK4TjwntK6hcZwdYeJUuSxZqdR7xZKP0C2BaR0skM4xtk8P02 398H1hMSoinPf9hPDnTuKJVMFbCJK7cLUuAYeCgJUXzGqTs3g/ZLwUqNy4w04By258Yb PFFO+WHnHfG8QBVZOmEKF5EMvxSYYDJ+j2HJD/C7JiGJ4m5bV8ETPtWjTSflbUWS2Ffs gL+psF7kYOHR02tzvc/frtlCRh7xAaAEA8TygTipbWVQ7IGrrlTwWQcmb91tkY8HsUZ2 /FxHEAvsx68EcU53cmU/44xu+Bb10wdFnPp+cQGorS0vdKrJRArwBwBNN01aKVscmStg 2mNQ== X-Gm-Message-State: AOAM533yyyjmjJPqM5qekAv1XEB1ZmEA0p45LY7Y6+eImnNQg74scWfY WiFuWSzQAApejK3gvQ/UptzCjr4m6l/FPQ== X-Google-Smtp-Source: ABdhPJyBeW6yS54mx3zb7XeIjt+Mq64JOok9NE12PD92TfxI/HB3fkA02fRPfztyH2IxO22/Mh1lTA== X-Received: by 2002:a05:6402:177b:b0:433:426d:83ea with SMTP id da27-20020a056402177b00b00433426d83eamr12900874edb.18.1655299318654; Wed, 15 Jun 2022 06:21:58 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id d9-20020a1709063ec900b006feb6dee4absm6326761ejj.137.2022.06.15.06.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:58 -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 v4 20/23] tools: relocate-rela: Check that relocation works only for EM_AARCH64 Date: Wed, 15 Jun 2022 15:21:16 +0200 Message-Id: <36f26c8752335239344b265e5ddedad10e9cac8b.1655299267.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 13:21:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643765 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=lluRBOxO; 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 4LNQz84bpbz9sPC for ; Wed, 15 Jun 2022 23:25:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08B4C84536; Wed, 15 Jun 2022 15:22: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="lluRBOxO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B61484503; Wed, 15 Jun 2022 15:22:06 +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 D491B84503 for ; Wed, 15 Jun 2022 15:22:00 +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 x62so16107373ede.10 for ; Wed, 15 Jun 2022 06:22:00 -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=lluRBOxOFLYOvKHpGtL7qB+P9LF47Du7meO1/DSx8/4NYH4BDfZOAQa01/CkfEQ2ci vOJMCFHO8DMzXGMQ8ycGqt/okJqV94D7+8wLb1l/VHuhs0pBw6Y/9c2pvQCQGmOg7B0x gYCjw5WtVJYNn8z1zJdQCeaa9uqTFoZFmcubaQ4WXDXtZ/GcXOFZYHX+/OS9+pqgLls1 EU1slHCDvkuQwtX2v+Clk5noW6m9zbdL3+Ze+rshNGOunDCEWIzNQB9LVywwdA7HE17Y ntMQ/ABXk1cw7z2uNqw348SxR2hkl72UnN5Agrv9mgl9W8VEfXtEsSO9dUrFEY2RZFYH pHJw== 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=0vO4/sjrikKF6yHoYE66ZW2UVMtOQPrIf7W6DcrgKsFfD7p7uPRDzUqBVdOUZ8q36+ YSoI4XRfPs9r6zRTGXgSGFamrD04OI9GmqzV+M8xDTd7wr6KSGtLSgp8hayptrpqYKwR vj1mMoPeU99bUKxh6BFxMPb0cu45WBsv/FqyuBIlRpqq8/RWPPMebkkBTWGiUQ7OynPf hoDpFew98CpxBykNsofdqlaUmhPnVXdtV1L6LEa/pgAze0ACjzaO8mEAy8bbXqUqFZab gIow2OclDJFzwN63HjZOpDN9c71nXN7oeZHQ0QWz2+0wEJ0QEHENVoDAxmK33bt2dq8P 2KUg== X-Gm-Message-State: AOAM532DBtMexyvkpeg83Qp2GiRJB6h65FGDkoVPEumrWglvRxsKaWUG GxfdNyQ15T3/9vXUfFugczGCaF4HA8ohmA== X-Google-Smtp-Source: ABdhPJy7f8SMQIwoShEtRPGpEHAI188nso9uUyGTgae90wm7ttZEmJ2ua1yZZzzvPpJX8LtJfDsEnA== X-Received: by 2002:a05:6402:847:b0:42d:91ed:82f3 with SMTP id b7-20020a056402084700b0042d91ed82f3mr13160864edz.416.1655299320335; Wed, 15 Jun 2022 06:22:00 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id b7-20020a056402278700b0042fb3badd48sm9505338ede.9.2022.06.15.06.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:21:59 -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 v4 21/23] tools: relocate-rela: Add support for elf32 decoding Date: Wed, 15 Jun 2022 15:21:17 +0200 Message-Id: <7491cc72fe04cbd48db014f1492ce463e91dfb42.1655299267.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 13:21:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643766 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=YnQez/y9; 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 4LNQzM1JB1z9sPC for ; Wed, 15 Jun 2022 23:25:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 144888453B; Wed, 15 Jun 2022 15:22: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="YnQez/y9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6E3F84514; Wed, 15 Jun 2022 15:22:06 +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 912BF84510 for ; Wed, 15 Jun 2022 15:22:02 +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 c2so16130279edf.5 for ; Wed, 15 Jun 2022 06:22:02 -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=YnQez/y9q/m1JnNYX4cGkSjxG+QGaBozqoOdk9nV00AJOmudEb+iuXkaFIeahdY7lf H2sEIUl6KB4FRM76ukf7FQpfPEkFyRi/AZFR/NKSoi3AKqBBGK/eF4TMEAby7vZaxsmh /eEyQbXTAbjSwxUbIeRFiNVcK9oiCSoDCkb4Pl7PI9gBwrWNQOYWBGbgI3sSUwedAoyR yc5ke+bMXeK64mkuraIdw0JzKyOx7EchG3RbEAobi182oIv1UZTROIr1GpZVqKvXgVOz CYICNK7vov26KQpg2OmEM1NPtgh5g9O7aqwvO9tyto2PE+M/WGUCNEFVDA5Z/vtvhLkA Jn4A== 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=C5kJaiPZ8yFJx9FY1eOMAEWE5qR4KWmN5y1OgJrgHTodGoAlGtceAH/VWlUZGX2ssq Z+qn1diqlf367/P+2IS20ozH2eQdcXRfUG4D1kW2TswYpQhFAabZPMh/pZpGXVm0RggR G7lX/98lCwsi5M1RMCeUADqK7A9mVYDtuVwXTe3Eps8egtPUmvLZx+IcKvp9KxB1eP71 Wy2ko0p/SQhmtS2QCP7lXg3JILFDff1RpHDutC/D8NY5vGhJius6wMpzkO67E7i8rfqa Mi44/asW+T+IHKMBpWOh4RO7Pgb2VVHl8BUUcCyQSNHfdfzR/4C2F5Ue6JOEtVHu52P6 ljfA== X-Gm-Message-State: AJIora8dcCVkhFQ7/lYiRrK2obNIyaBPZDvRSeUFh/H7ZLG+nKvLZf3d WCuZrOK0IdnJRCevOV9oZS/TagvRg6v8wQ== X-Google-Smtp-Source: ABdhPJwkOCHIfNHb4Wm2sb38/TnNl9ILSFtRfRiZZaAp7mgRZjo2kKvr36ESPnDw2oihDuqfhL48KA== X-Received: by 2002:a05:6402:32a6:b0:42d:ed8b:3d8 with SMTP id f38-20020a05640232a600b0042ded8b03d8mr12734434eda.225.1655299321872; Wed, 15 Jun 2022 06:22:01 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id yz15-20020a170906dc4f00b0070ad296e4b0sm6301189ejb.186.2022.06.15.06.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:22:01 -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 v4 22/23] tools: relocate-rela: Add support for 32bit Microblaze relocation Date: Wed, 15 Jun 2022 15:21:18 +0200 Message-Id: <9912c3d76933bdf75e1ebb6aab43726cd32cafb5.1655299267.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 13:21:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1643767 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=PsEdy4vb; 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 4LNQzY5LZLz9sPC for ; Wed, 15 Jun 2022 23:25:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9477084542; Wed, 15 Jun 2022 15:22: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="PsEdy4vb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C721A84521; Wed, 15 Jun 2022 15:22: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=unavailable 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 4947184519 for ; Wed, 15 Jun 2022 15:22:04 +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 bg6so23331838ejb.0 for ; Wed, 15 Jun 2022 06:22:04 -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=mkS9hCP5Cp+VjwVBaNpzgwt8p2NPlr+99fTVzk1vBP0=; b=PsEdy4vbjfTGHdV2K0gvGc21sDz3huAYQpTrHwb7QtnufUWRDR4j/7McekqzEW+W08 Yi/RIl4koOgH7eBazUoAGVAIvKcdanKb+ikf5X8YuvKvo+0AOHyDVhkEPTJZzbj3s7qv LBe3ckcWYujmrZ4Xb1VOI9OxVf8NR99iQtNX4GhKSIobNmv1Qo9/Dyj+tOYtEzIn/PgK VBr/0SbZdWBzQLYwDvLmDBV/2WNZujBZoIroYiE66+tFEsuOV06dGP77jvhQqJj/00Jh WFw6AfdNwhDE04yLKB7UPnQFxKwIGgNMCf4hpxNZOpv7pFpUX29eRcowCc7kC6WBU0LU M6CQ== 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=mkS9hCP5Cp+VjwVBaNpzgwt8p2NPlr+99fTVzk1vBP0=; b=dWsEljH7OCIk/JK4J3HIVgAvwgfo4NIZULLnSZc4ioB6R2W5wGu88yOeGJKyY7F3Qo J1MBr1uLhG4/9fZ3/JrcUDN8cKTg6ZXWXKwV1HGxrz+b3cCTaX43qpeSlNnEb5xRE9qt eFcuUXEsBo/sGrmxTAb9n0vQ2HthuHhIAb/bi03Vmm2s+BXr92wHGtn02tU+3c5cVt9F O7wL4nDjvo31LG4RT8I5HQtGs+wKcEYofsSMXtlRsA/Kj3PkiuAL9fz7cAnxkTSmAgKA tncyBDt+2Cb0y/Re6xLdyUrVzah/+bRH3osX9nQumpw2S9N//DlIVtu0PtNuxz2j2u91 pukA== X-Gm-Message-State: AJIora+xaT3GvNNZUBDG6GLstJy3qWB8lRlpiKItHn9fTCRFdSo25SvA Z7QHumekCucITIPalXO+XDKxnDcsRsqd9g== X-Google-Smtp-Source: AGRyM1u1XY2Z9qgbtioEuuJikq4LYuonuaW+yLb8VHxSAsne+oiNr5HfU/fz14WBL2GnsmiFE6/zTA== X-Received: by 2002:a17:906:14d5:b0:711:c55a:998 with SMTP id y21-20020a17090614d500b00711c55a0998mr8814858ejc.708.1655299323538; Wed, 15 Jun 2022 06:22:03 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id fm15-20020a1709072acf00b00718d18a1860sm2715053ejc.61.2022.06.15.06.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:22:03 -0700 (PDT) From: Michal Simek X-Google-Original-From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Angelo Dureghello , Heiko Schocher , Heinrich Schuchardt , Huan Wang , Marek Vasut , Michal Simek , Ovidiu Panait , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v4 23/23] microblaze: Add support for run time relocation Date: Wed, 15 Jun 2022 15:21:19 +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 --- Changes in v4: - Aligned NEEDS_MANUAL_RELOC for m68k arch/Kconfig | 4 -- arch/m68k/Kconfig | 3 + 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 + 9 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 arch/microblaze/cpu/relocate.c diff --git a/arch/Kconfig b/arch/Kconfig index 02de32f9c77f..d91475d24747 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 @@ -76,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/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/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