From patchwork Sat Mar 11 17:38:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1755781 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mv13AS/f; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PYqsj4995z1yWv for ; Sun, 12 Mar 2023 04:39:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7EACD85FD1; Sat, 11 Mar 2023 18:38:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="mv13AS/f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C632085FD0; Sat, 11 Mar 2023 18:38:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS 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 59F1685FC9 for ; Sat, 11 Mar 2023 18:38:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x536.google.com with SMTP id r15so5873386edq.11 for ; Sat, 11 Mar 2023 09:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678556331; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m38ZfsG9kmQlXmcHeei6E9gHSZSMgR6T+ou/p60AdZA=; b=mv13AS/fg0hJt2qj581btQSaWRtbXon1TTR01Pl7yLNvcnbTvfb1XqWLu7ooh51xNh 9bv2RnPp9y+zq9j9UzE88m7QDOTgjKXmEVJoxEVzM/0xtQi1LkCkd5K28fWVUgb/RY/s zlCjMoF9+xHIIwmWLrRJ8FdULKLUD+D8/YABF/ZZGyW5OfnKLMPAPlzMS31fKUyDAAnw Vv/xPdUdb6M4kt7T1bKI/arw7PMwyK/BLOoZjZOoJHoLk1YuvHIzQxfyEkCp/Dq909zn u1Q0g4M0i3KZI9g9DUDV6cz2xJj9d73QMx2xOdtTqh2o8AbeIbjOBgAtFvpBSbsGqldX ojUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678556331; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m38ZfsG9kmQlXmcHeei6E9gHSZSMgR6T+ou/p60AdZA=; b=OlPRxPn4xgOu7MUPhK2p1UpBPCxr8JhSKZzUFLca/zPENWGmvmWgnFZ4rEy8GdB87T NY4lX0hHrk1QiRKgwXWRKkPaO50g9vvpABpkJoDRVlhpEjNzoy1EzBQfuD0ln9giVu6R CrdstVOXD21MHdrI0kEnqxdNBmoNKeGXAYlBQeLJS5FNQQixddMBUF6i2iB10Y03qqA0 G4RLPUI1kJ0pGodrHjJhBTiL68NVvjsrhwUlHprGqkr+YDRrLmTSQCEssBDkl1JTwLQj WMFIzQtg4TmAMWjxSi6UQAy0Hc2cqajdBo6sFf1JwNaSFqABFcPCj3/YzLF2EEi9uvsq 2DgA== X-Gm-Message-State: AO0yUKV43gt44HRT8wXNE1Gf5gVkCODHdDovIKShRhqXeUkSD5DzqnMr bUKlmYvjG2hMTPIvJeLz/X/Kz6mgPzY= X-Google-Smtp-Source: AK7set9Axw2oKcufFle9I+8BtPLzMnwLBnqsYS7Gc+wMrXeAIx2lT3H/SkXBY8C42wbvX/sc1qXccw== X-Received: by 2002:a17:906:db05:b0:889:5686:486a with SMTP id xj5-20020a170906db0500b008895686486amr35530224ejb.30.1678556330805; Sat, 11 Mar 2023 09:38:50 -0800 (PST) Received: from localhost.localdomain ([2a02:2f0e:c915:3800:d24b:dc4a:599b:7c80]) by smtp.gmail.com with ESMTPSA id p10-20020a170906614a00b008e7916f0bdesm1303986ejl.138.2023.03.11.09.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 09:38:50 -0800 (PST) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Samuel Holland Subject: [PATCH v2 1/5] tools: relocate-rela: adjust le64_to_cpu -> le32_to_cpu in decode_elf32() Date: Sat, 11 Mar 2023 19:38:34 +0200 Message-Id: <20230311173838.521804-1-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 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.8 at phobos.denx.de X-Virus-Status: Clean The sh_addr/sh_offset/sh_size fields in Elf32_Shdr are 32-bits wide, so use le32_to_cpu() instead of the 64-bit variant. Fixes: 5e0e1a86d327 ("tools: relocate-rela: Fix ELF decoding on big-endian hosts") Reviewed-by: Michal Simek Signed-off-by: Ovidiu Panait --- (no changes since v1) tools/relocate-rela.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 2d2a2ed277..689e2d4655 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -316,9 +316,9 @@ static int decode_elf32(FILE *felf, char **argv) debug("%s\n", sh_name); - sh_addr = le64_to_cpu(sh_table[i].sh_addr); - sh_offset = le64_to_cpu(sh_table[i].sh_offset); - sh_size = le64_to_cpu(sh_table[i].sh_size); + sh_addr = le32_to_cpu(sh_table[i].sh_addr); + sh_offset = le32_to_cpu(sh_table[i].sh_offset); + sh_size = le32_to_cpu(sh_table[i].sh_size); if (!strcmp(".rela.dyn", sh_name)) { debug("Found section\t\".rela_dyn\"\n"); From patchwork Sat Mar 11 17:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1755784 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=P5ZXt/PJ; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PYqt537Zsz1yWv for ; Sun, 12 Mar 2023 04:39:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 496FC85FC2; Sat, 11 Mar 2023 18:39:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="P5ZXt/PJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BDDCC85FD0; Sat, 11 Mar 2023 18:38:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 44F9E85FC0 for ; Sat, 11 Mar 2023 18:38:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x531.google.com with SMTP id da10so33142253edb.3 for ; Sat, 11 Mar 2023 09:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678556332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zy6l77xoCw1h6YQvd3B5rd/H2RlJq9ow4IXIs4mKzFI=; b=P5ZXt/PJZDYjsxAmc7xj07WpLNboBSqaQB+gpcqqeCNICbfRpoq5gi7AaVP5cPsSqh OH1x23VWWpPvSUblt7BbIKLmp++PxGxuhmnPjirVOxEVS1siZsr8GiI0w+qAjxZgGq69 npUJ/iqZRhEJWBnAK0JeeO90LvFLbEjxBd4hsDQXaQbfkLLCVpH+/aOf9YXbdPTF5iqz hzb5iEQSGkN+xZ1DG3yij+dDAINZICkk2ompQLXKnRSkznPyrKdH+zCTAgWfO3DXzA3Z DF0rHL2xZSMB3eKa9vQ0ixs3IAWZW6wMIwhC/rySD+DzUF+60lDIwZ4eeiax0dmpXSrc OQDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678556332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zy6l77xoCw1h6YQvd3B5rd/H2RlJq9ow4IXIs4mKzFI=; b=E0RfJxmd71nTyQbQAEWpvkF31DU9s/oH/hBh6/DM1aBcjS6xjhcKlJxAK4kqnSZJL2 3VFQpb1qV3+h5AkqlifPrCzxftDDa8T+yLcNnilcdQsDjCu6hQG3r0uKaW2pulCJ9CX/ yLX21fuv5USphbA4jZRuSR4V6GVLUsldCQkByCHHuqAeqfTDGUo96mta29t7sz5WRcGC 6xajv7ePPitV+WNt00jmPQPz2utDBXNDkvYhbIWt5F/gSo/vLipL1Z97cMjAVCtlf/lq 2jnlYAP8tK3mdtejPA+GPVtwxraTnW19MIllRkpvfGb5OITEspTlG5XqyfbE0UuFwu8j bJyQ== X-Gm-Message-State: AO0yUKXjrAJ2ckFcb8X2N/ZnT1uG5Pm2ZRwMA21qljEMc3t+oOgka487 kT06mqL/0jj3CG+O8fVibFcQpVQXw7Y= X-Google-Smtp-Source: AK7set/UxAAU53xc9CiogRPoASARVvBBHZWBxohMuYra/e6XD/yH3TlHhwjsDX84KvtWMFrCSYtO7w== X-Received: by 2002:a17:906:fe41:b0:8f1:949f:37b5 with SMTP id wz1-20020a170906fe4100b008f1949f37b5mr35809412ejb.32.1678556331715; Sat, 11 Mar 2023 09:38:51 -0800 (PST) Received: from localhost.localdomain ([2a02:2f0e:c915:3800:d24b:dc4a:599b:7c80]) by smtp.gmail.com with ESMTPSA id p10-20020a170906614a00b008e7916f0bdesm1303986ejl.138.2023.03.11.09.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 09:38:51 -0800 (PST) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Samuel Holland Subject: [PATCH v2 2/5] tools: relocate-rela: introduce elf16_to_cpu() and elf32_to_cpu() Date: Sat, 11 Mar 2023 19:38:35 +0200 Message-Id: <20230311173838.521804-2-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230311173838.521804-1-ovpanait@gmail.com> References: <20230311173838.521804-1-ovpanait@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Add elf16_to_cpu() and elf32_to_cpu() functions that allow to read data in both big-endian and little-endian formats. Reviewed-by: Michal Simek Signed-off-by: Ovidiu Panait --- Changes in v2: Replaced hardcoded 0x1 values with ELFDATA2LSB. tools/relocate-rela.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 689e2d4655..b27c41b96f 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -45,6 +45,7 @@ #endif static int ei_class; +static int ei_data; static uint64_t rela_start, rela_end, text_base, dyn_start; @@ -61,6 +62,22 @@ static void debug(const char *fmt, ...) } } +static uint16_t elf16_to_cpu(uint16_t data) +{ + if (ei_data == ELFDATA2LSB) + return le16_to_cpu(data); + + return be16_to_cpu(data); +} + +static uint32_t elf32_to_cpu(uint32_t data) +{ + if (ei_data == ELFDATA2LSB) + return le32_to_cpu(data); + + return be32_to_cpu(data); +} + static bool supported_rela(Elf64_Rela *rela) { uint64_t mask = 0xffffffffULL; /* would be different on 32-bit */ @@ -384,6 +401,9 @@ static int decode_elf(char **argv) ei_class = e_ident[4]; debug("EI_CLASS(1=32bit, 2=64bit) %d\n", ei_class); + ei_data = e_ident[5]; + debug("EI_DATA(1=little endian, 2=big endian) %d\n", ei_data); + if (ei_class == 2) return decode_elf64(felf, argv); From patchwork Sat Mar 11 17:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1755785 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=HpkEltjQ; dkim-atps=neutral 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PYqtB1XL5z1yWv for ; Sun, 12 Mar 2023 04:39:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 190A485FDB; Sat, 11 Mar 2023 18:39:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="HpkEltjQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9423185FCB; Sat, 11 Mar 2023 18:38:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 0AF0285FCB for ; Sat, 11 Mar 2023 18:38:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x533.google.com with SMTP id cn21so2869501edb.0 for ; Sat, 11 Mar 2023 09:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678556332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AKp4d/zjLIGCFH3ikFRvdJblSW/55iOpuzBSPPH4rt0=; b=HpkEltjQkw3No9LuTYJegLErtkSeh9wTkoCsNqU3IfSy/rjGfEjnxpsP8FeWo1077A lJFTeWY81/t0nLRSyiWBzzSyy1zyhVBTBX7EEq97eI8iJuPAWVl02nwAI/JFRIuOK1Dx ri/M+xUlgf2nKzapI6f9SD0YRTyJSPoRaKOvOEruUlwZHz6MVH+DNEmCkbJBIZCLNCeq 5opmFplQwZuevlJ1jpzQjNyNQ88dkwlfCX1fw8QGwwDUSyXdBdTefwTLehvFStmAT18U CXxBwsaHEGv+2zrNGcamw3SfSjiO+zxyv92mi/6xAaZNMUpfvEHV/Xe5NagaBb78Iq7R HrCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678556332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AKp4d/zjLIGCFH3ikFRvdJblSW/55iOpuzBSPPH4rt0=; b=NnWCRa2ztz5FCxPLnYrDpVwUhkS21zGgyMbmlCHHLAi5Ugv7LhwFpevkBbAdxTNSFJ tSanvJogRAATzysm79XlQFqMFPtHK/MJ2nvLWTCiXJD7yJOhXWt77QRsSKJX7M7EVi3m XCz6ivhXw6qvPkx1nZKY2XnVmc3cA+/yiIHHDLtdEPorRuz7954vVn/kiUtTg8enudFP nkJEuqHKj8M+abHZsREKUm3s9/i/ezqUbY3E0YO9r2OMCug+Zi5LjqwDZE9BORGY9J/5 5L+uJvwsKkPe/LZ5fv57zwJfM9vg3R0RJ5YH8E/qDadxKUm9Yn+FPRRVvSXEm7wyPWv+ uNWQ== X-Gm-Message-State: AO0yUKXIUPYf03rbqx9mMHCvQtglHaNsNp7Lc7hm4jy52su28Mi1hnBG XxRTq2Ryxt3v7MprjMPKcKTvee+Cg04= X-Google-Smtp-Source: AK7set+ROOnCbLsq7mzeN84OqK2AJfP4EWOq0Qto5LL372F6r9VBy+4s4a2KhopZp71awg1K+bc2rQ== X-Received: by 2002:a17:906:d928:b0:8b1:7eaf:4708 with SMTP id rn8-20020a170906d92800b008b17eaf4708mr28004163ejb.65.1678556332697; Sat, 11 Mar 2023 09:38:52 -0800 (PST) Received: from localhost.localdomain ([2a02:2f0e:c915:3800:d24b:dc4a:599b:7c80]) by smtp.gmail.com with ESMTPSA id p10-20020a170906614a00b008e7916f0bdesm1303986ejl.138.2023.03.11.09.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 09:38:52 -0800 (PST) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Samuel Holland Subject: [PATCH v2 3/5] tools: relocate-rela: add support for handling 32-bit big endian files Date: Sat, 11 Mar 2023 19:38:36 +0200 Message-Id: <20230311173838.521804-3-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230311173838.521804-1-ovpanait@gmail.com> References: <20230311173838.521804-1-ovpanait@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Currently, a microblaze build with CONFIG_SYS_BIG_ENDIAN=y and CONFIG_STATIC_RELA=y fails with: tools/relocate-rela: Not supported machine type ELF decoding failed make[2]: *** [u-boot/Makefile:1306: u-boot-nodtb.bin] Error 1 To fix this, convert the 32-bit codepath to use the previously added elf{16,32}_to_cpu() functions. The aarch64 codepath is left untouched. This commit ensures that CI doesn't fail for the next patches which enable runtime relocation by default for microblaze. Reviewed-by: Michal Simek Signed-off-by: Ovidiu Panait --- (no changes since v1) tools/relocate-rela.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index b27c41b96f..fe8cd6bda9 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -251,7 +251,7 @@ static int decode_elf32(FILE *felf, char **argv) return 25; } - machine = le16_to_cpu(header.e_machine); + machine = elf16_to_cpu(header.e_machine); debug("Machine %d\n", machine); if (machine != EM_MICROBLAZE) { @@ -259,10 +259,10 @@ static int decode_elf32(FILE *felf, char **argv) return 30; } - text_base = le32_to_cpu(header.e_entry); - section_header_base = le32_to_cpu(header.e_shoff); - section_header_size = le16_to_cpu(header.e_shentsize) * - le16_to_cpu(header.e_shnum); + text_base = elf32_to_cpu(header.e_entry); + section_header_base = elf32_to_cpu(header.e_shoff); + section_header_size = elf16_to_cpu(header.e_shentsize) * + elf16_to_cpu(header.e_shnum); sh_table = malloc(section_header_size); if (!sh_table) { @@ -290,8 +290,8 @@ static int decode_elf32(FILE *felf, char **argv) return 27; } - sh_index = le16_to_cpu(header.e_shstrndx); - sh_size = le32_to_cpu(sh_table[sh_index].sh_size); + sh_index = elf16_to_cpu(header.e_shstrndx); + sh_size = elf32_to_cpu(sh_table[sh_index].sh_size); debug("e_shstrndx %x, sh_size %lx\n", sh_index, sh_size); sh_str = malloc(sh_size); @@ -306,8 +306,8 @@ static int decode_elf32(FILE *felf, char **argv) * Specifies the byte offset from the beginning of the file * to the first byte in the section. */ - sh_offset = le32_to_cpu(sh_table[sh_index].sh_offset); - sh_num = le16_to_cpu(header.e_shnum); + sh_offset = elf32_to_cpu(sh_table[sh_index].sh_offset); + sh_num = elf16_to_cpu(header.e_shnum); ret = fseek(felf, sh_offset, SEEK_SET); if (ret) { @@ -329,13 +329,13 @@ static int decode_elf32(FILE *felf, char **argv) } for (i = 0; i < sh_num; i++) { - char *sh_name = sh_str + le32_to_cpu(sh_table[i].sh_name); + char *sh_name = sh_str + elf32_to_cpu(sh_table[i].sh_name); debug("%s\n", sh_name); - sh_addr = le32_to_cpu(sh_table[i].sh_addr); - sh_offset = le32_to_cpu(sh_table[i].sh_offset); - sh_size = le32_to_cpu(sh_table[i].sh_size); + sh_addr = elf32_to_cpu(sh_table[i].sh_addr); + sh_offset = elf32_to_cpu(sh_table[i].sh_offset); + sh_size = elf32_to_cpu(sh_table[i].sh_size); if (!strcmp(".rela.dyn", sh_name)) { debug("Found section\t\".rela_dyn\"\n"); @@ -540,9 +540,9 @@ static int rela_elf32(char **argv, FILE *f) PRIu32 " r_addend:\t%" PRIx32 "\n", rela.r_offset, rela.r_info, rela.r_addend); - swrela.r_offset = le32_to_cpu(rela.r_offset); - swrela.r_info = le32_to_cpu(rela.r_info); - swrela.r_addend = le32_to_cpu(rela.r_addend); + swrela.r_offset = elf32_to_cpu(rela.r_offset); + swrela.r_info = elf32_to_cpu(rela.r_info); + swrela.r_addend = elf32_to_cpu(rela.r_addend); debug("SWRela:\toffset:\t%" PRIx32 " r_info:\t%" PRIu32 " r_addend:\t%" PRIx32 "\n", From patchwork Sat Mar 11 17:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1755786 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=fDDtRTrF; dkim-atps=neutral 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PYqtP6lQ9z1yWv for ; Sun, 12 Mar 2023 04:39:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 678A785FD8; Sat, 11 Mar 2023 18:39:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="fDDtRTrF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CB9E885FCD; Sat, 11 Mar 2023 18:38:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 DE68C85FC9 for ; Sat, 11 Mar 2023 18:38:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x533.google.com with SMTP id cn21so2869588edb.0 for ; Sat, 11 Mar 2023 09:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678556333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W4+8hg1pwWV/BiIC1WBWuWOrcupgDVTfjmf/DGuF4nk=; b=fDDtRTrFdnLKHosUffD23L8m7bMCuTFYFSJXmSrCk7etSwXJDjecv7DqX5XV3aVceY qX4cKPANk9IqpKu444eY2u+MOysNbIYe6xFvUl+hwm+AVDJP+fnRl1Pery019fFii6pi hdP2K3K39SkwRTEmVgnqdoTQyTZEiwAXD5uSuP/W4k93gDkYFyagPmfuR0LjOERymt8g Ojw4UHldmBG63jpCHuN2pHQzclJeSba7vQe0t/fTw7Crx/4YZ+2ECyXS5CNZr/pGW6u2 9Xi43/RUycqShJjXHj9X53hnNzMTciX6FnsUDm5XzrUpJsTBXybkrScIW4XMMtOPJsBm Sz3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678556333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W4+8hg1pwWV/BiIC1WBWuWOrcupgDVTfjmf/DGuF4nk=; b=IWZglJtwb+fa+ZhvMiZGy5eKgJIPim+55X1j9b8r/QjLw9Wj6R3ttfd8xJokbwp7k/ 9sg8QY2W4BRIl6dVb6cP5rm/qOsTFgaQEQjvYSOkx8/KbYOvW1Xepgt0oWDk9R2ztxXo uVU5LUeI6AlsF1teVY+FNtJoo05PHXvO9T0Whz3K0x1oz/xENU9fNx80hCKd6QWZJRzJ 9h31jiYjqPIa5UpO0Potywi6h2fIKqZkazUzwFCh1iZhu3yLDUR2RXKZCjfQnbievR1P Al9OPZXKBzqHK4KA/QhyFIEyYzYWffpZzPx4GQVOOsxzYWUU/Av9f0q5zx7Ol1/MnaT/ Mukg== X-Gm-Message-State: AO0yUKXAwAvOprkSYV9WAtzatcnYgkjQ2BxPvnSFLRjKD7xGZpFKUMre TJIl99xMiPUIi+3XETHxucMg56NoDVY= X-Google-Smtp-Source: AK7set9IClrNeVgGgccPEdmaGEUiTZJRoE7wWZfi6WcjvNDL6UKFVdmrlxQN5RxeCsxuCg5usnd5HQ== X-Received: by 2002:a17:906:1450:b0:8af:ef00:b853 with SMTP id q16-20020a170906145000b008afef00b853mr25593274ejc.73.1678556333583; Sat, 11 Mar 2023 09:38:53 -0800 (PST) Received: from localhost.localdomain ([2a02:2f0e:c915:3800:d24b:dc4a:599b:7c80]) by smtp.gmail.com with ESMTPSA id p10-20020a170906614a00b008e7916f0bdesm1303986ejl.138.2023.03.11.09.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 09:38:53 -0800 (PST) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Michal Simek Subject: [PATCH v2 4/5] microblaze: drop CONFIG_NEEDS_MANUAL_RELOC Date: Sat, 11 Mar 2023 19:38:37 +0200 Message-Id: <20230311173838.521804-4-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230311173838.521804-1-ovpanait@gmail.com> References: <20230311173838.521804-1-ovpanait@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Microblaze and m68k are the only remaining architectures that still enable CONFIG_NEEDS_MANUAL_RELOC by default. Microblaze has had runtime relocation support using CONFIG_STATIC_RELA for quite some time, since commit d58c007498 ("microblaze: Add support for run time relocation"). Drop support for CONFIG_NEEDS_MANUAL_RELOC and make runtime relocation the default, as the rest of the architectures do. Reviewed-by: Michal Simek Signed-off-by: Ovidiu Panait --- (no changes since v1) arch/microblaze/Kconfig | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index ce157a79cc..e38c9f6d71 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -4,19 +4,8 @@ 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 + def_bool y choice prompt "Target select" From patchwork Sat Mar 11 17:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ovidiu Panait X-Patchwork-Id: 1755787 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=M1LDjvof; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PYqtf1yj1z1yWv for ; Sun, 12 Mar 2023 04:39:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 579E485FD4; Sat, 11 Mar 2023 18:39:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="M1LDjvof"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 49E1E85FC9; Sat, 11 Mar 2023 18:38:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 F196C85FC0 for ; Sat, 11 Mar 2023 18:38:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-ed1-x535.google.com with SMTP id x3so32982507edb.10 for ; Sat, 11 Mar 2023 09:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678556334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MrZm70QsxV0vNLJKkFKy4s2AKRQUAXLoV/fj00AQkhc=; b=M1LDjvoflKHH6QYd+PeE1yyLJfX/06guFxc9rcVnId8o11N+uU0wJKyUxnL1HcVkTw iS6opxNciweHzu5xG13phur3wdzunFbclJ/DBJB67/zKkRk2T8BDCxrBspZReEI6mVym tX4dyIezlTBQsqyHogVFb2p84+l3YUEKMgd0+4QDxRT+jB1WOfMzzj5zjv2k5K1mhbaO sLenyR8lwCJ0fiZFv0Ondz/uWUQDlS3cm8eL+xaIgDVo5nI4XO+CC0w8vn38nKkXYSef 7c0du6sAa07S6mIagarAfbwiWm5XB5kE+LEml6QH5dlTLo1WnuEtmDYvKciexv1OpNJ4 LUpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678556334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MrZm70QsxV0vNLJKkFKy4s2AKRQUAXLoV/fj00AQkhc=; b=2B1almV7Es/z7TgxeBdyHkRMsWUIRJdeR92iBIikz8bg50pph1tiQwyqDUmAZ/5ooD 6Pt7TR5nuIND1YBizJ2LhgfbYdvBJgdnv4apvQDcnkbxupbnKRcV/W5qyFjx269bjZT6 TSsyk7ut+nI3O6Eur+EMJmCdvgL4TlRfK44vx/eRp5LSyjIEzskMZNYcYNYbAnROWKvl YoAO8WcGJPanEmEwvqzSzX4BvKUcoBlSXYbVAYY4jK8tLKEUS8ZiJdCPQ8axMcGrS9WR 4yJCPw3DG0AAPixrZJV/zZyCeHQfZ7oR9Ts86G/GsTCe6eTNBElznPlLwzOmyPQp0Wou GP3w== X-Gm-Message-State: AO0yUKWu2u9TK29C4owBkPtTS3uI9bkLL5Nt+phLmR65mhx9jd+g6uVJ vIB+c8nGdDZtMPPwmPRRh7IhJ16DUfM= X-Google-Smtp-Source: AK7set8mSwuGCdsos5TEzKpLbWGTeIgDF2xnZqIj3clZ3MPuIN6icczlq5XFJNNczpjKpQXb3xzUyQ== X-Received: by 2002:a17:906:66cd:b0:878:605b:ffef with SMTP id k13-20020a17090666cd00b00878605bffefmr31671011ejp.55.1678556334627; Sat, 11 Mar 2023 09:38:54 -0800 (PST) Received: from localhost.localdomain ([2a02:2f0e:c915:3800:d24b:dc4a:599b:7c80]) by smtp.gmail.com with ESMTPSA id p10-20020a170906614a00b008e7916f0bdesm1303986ejl.138.2023.03.11.09.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Mar 2023 09:38:54 -0800 (PST) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: Ovidiu Panait , Michal Simek , Michal Simek , Simon Glass Subject: [PATCH v2 5/5] microblaze: drop remnants of manual reloc Date: Sat, 11 Mar 2023 19:38:38 +0200 Message-Id: <20230311173838.521804-5-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230311173838.521804-1-ovpanait@gmail.com> References: <20230311173838.521804-1-ovpanait@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean Runtime relocation has been made the default for microblaze, so do the following cleanups: - drop all manual reloc codepaths in start.S - drop all STATIC_RELA ifdefs, as it is now enabled unconditionally in Kconfig Reviewed-by: Michal Simek Signed-off-by: Ovidiu Panait --- (no changes since v1) arch/microblaze/config.mk | 4 ---- arch/microblaze/cpu/Makefile | 3 +-- arch/microblaze/cpu/start.S | 28 ---------------------------- 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk index 467c5ca1b1..64c3f31319 100644 --- a/arch/microblaze/config.mk +++ b/arch/microblaze/config.mk @@ -13,10 +13,6 @@ LDFLAGS_FINAL += --gc-sections ifeq ($(CONFIG_SPL_BUILD),) PLATFORM_CPPFLAGS += -fPIC -endif - -ifeq ($(CONFIG_STATIC_RELA),y) -PLATFORM_CPPFLAGS += -fPIC LDFLAGS_u-boot += -pic endif diff --git a/arch/microblaze/cpu/Makefile b/arch/microblaze/cpu/Makefile index 1c586a7de0..b8c1dcbe14 100644 --- a/arch/microblaze/cpu/Makefile +++ b/arch/microblaze/cpu/Makefile @@ -5,7 +5,6 @@ extra-y = start.o obj-y = irq.o -obj-y += interrupts.o cache.o exception.o cpuinfo.o -obj-$(CONFIG_STATIC_RELA) += relocate.o +obj-y += interrupts.o cache.o exception.o cpuinfo.o relocate.o obj-$(CONFIG_XILINX_MICROBLAZE0_PVR) += pvr.o obj-$(CONFIG_SPL_BUILD) += spl.o diff --git a/arch/microblaze/cpu/start.S b/arch/microblaze/cpu/start.S index 7079d9e170..c1e0fcda0a 100644 --- a/arch/microblaze/cpu/start.S +++ b/arch/microblaze/cpu/start.S @@ -10,16 +10,11 @@ #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 @@ -35,7 +30,6 @@ _start: addi r1, r0, CONFIG_SPL_STACK #else add r1, r0, r20 -#if defined(CONFIG_STATIC_RELA) bri 1f /* Force alignment for easier ASM code below */ @@ -67,7 +61,6 @@ uboot_sym_start: brlid r15, mb_fix_rela nop -#endif #endif addi r1, r1, -4 /* Decrement SP to top of memory */ @@ -310,7 +303,6 @@ relocate_code: brlid r15, __setup_exceptions nop -#if defined(CONFIG_STATIC_RELA) /* reloc_offset is current location */ SYM_ADDR(r10, r0, _start) @@ -331,27 +323,7 @@ relocate_code: 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 - cmpu r12, r21, r22 - beqi r12, 2f /* No GOT table - jump over */ - - /* Skip last 3 entries plus 1 because of loop boundary below */ - addik r22, r22, -0x10 - - /* Relocate the GOT. */ -3: lw r12, r21, r0 /* Load entry */ - addk r12, r12, r23 /* Add reloc offset */ - sw r12, r21, r0 /* Save entry back */ - - cmpu r12, r21, r22 /* Check if this cross boundary */ - bneid r12, 3b - addik r21. r21, 4 -#endif /* Flush caches to ensure consistency */ brlid r15, flush_cache_all