From patchwork Thu Mar 19 15:06:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1258278 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=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: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=jyIVEIOC; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48jqyJ6XY1z9sf8 for ; Fri, 20 Mar 2020 02:07:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C0A6801D2; Thu, 19 Mar 2020 16:07:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="jyIVEIOC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79A838025D; Thu, 19 Mar 2020 16:07:16 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 68B82800DF for ; Thu, 19 Mar 2020 16:07:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-wr1-x441.google.com with SMTP id b2so3414609wrj.10 for ; Thu, 19 Mar 2020 08:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3kwPoMn73fT7sQmFkXp+Dg3oPxkuKV980riLlcqtCAc=; b=jyIVEIOCMvtpsBvsGkinzn4uJ5UadkFfwuOvOEFtSLvzgiDK7fLRc6wql1qN+liyJy vfhr0fcP3V7B+4pbvpjRArMF10ONIjPcbG86SwdcJCS8/uB9UjCAXHqlCPFc+W0jLJDk EitEiXV4Yz9bgmgJpf4OfhE9CUBVgd7fUjlrrYIw1ALN7HiMzjMLKuHZVzCvMsuBladJ PTVxlSH45M0JsaCtdlusoLhxLAbyiuHtAj3DnEkdOpxQwPLnhzd9Ut4/AkUUinK8s10g He5A50FSojlflR0r1HfWXHzy+DW/FBRZxQQqPHs385+qxr0cRNUBYXSZH5v9V+LNvfWS ke/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=3kwPoMn73fT7sQmFkXp+Dg3oPxkuKV980riLlcqtCAc=; b=l459+X0GKEqt8EWrLavF7bvQN+gWQNOUZzH+9nI0Ek4419zpo7caWXpcSgOAL9MPoE 50vfGVQ3yN+DsrflP37y3e4EN567XbwR5xSSh5QMK6wXCSCjXnhhkr/gFBFLa6dYR5Ff FP/TS94UHiLrbPIUI5SVMvbIO+Cc8cGZK8chOd1QNtmWwaOb8zjamVpEfDxG/ChMgyAa rW4cvypnRYdUpcDI4t9NxplCiaDzLX1QZW73kH96w7ULN6YsyVN4fPBMG5WdMaDJCYe3 G1Zud3w+7iiOuciWXYOhU+tgCG4VoarkXU6yOld/ggH6IKe3L6o1V0ogDd78O1Mk/85y cFWg== X-Gm-Message-State: ANhLgQ18FiHOJoJkJJPnhsUOdqFgpNJINPTtgvuZp8qf6fWKhvutAILK BB6phvv6PqKJ/gEszs4cyuFtkC7LUS42AQ== X-Google-Smtp-Source: ADFU+vtHrgIO5IRxUgeQuwMhfkSNciKIyfl0YD/aysQ3Cl3o7Kqy0iXJa0RFXxN6m9P9F2N5fktuVQ== X-Received: by 2002:adf:914e:: with SMTP id j72mr4914321wrj.109.1584630426559; Thu, 19 Mar 2020 08:07:06 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id q9sm3623903wmg.41.2020.03.19.08.07.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Mar 2020 08:07:00 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com, Tom Rini , sadanan@xilinx.com, mbodapat@xilinx.com, Masahiro Yamada Cc: Bin Meng , Fabio Estevam , Heinrich Schuchardt , Jagan Teki , Kever Yang , Marek Vasut , Simon Glass , Stefan Roese Subject: [RFC PATCH] arch: Add explicit linker script for u-boot-elf Date: Thu, 19 Mar 2020 16:06:59 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Commit f4dc714aaa2d ("arm64: Turn u-boot.bin back into an ELF file after relocate-rela") introduce REMAKE_ELF option to recreate u-boot.elf from u-boot -> u-boot.bin + DT -> u-boot.elf. The best is to ilustrate it from make V=1 output cat u-boot-nodtb.bin dts/dt.dtb > u-boot-dtb.bin cp u-boot-dtb.bin u-boot.bin aarch64-linux-gnu-objcopy -I binary -B aarch64 -O elf64-littleaarch64 u-boot.bin u-boot-elf.o aarch64-linux-gnu-ld.bfd u-boot-elf.o -o u-boot.elf --defsym="_start"=0x8000000 -Ttext=0x8000000 Last command has no explicit linker script passed that's why toolchain internal linker script is used. In Binutils 2.32 case it contains SIZEOF_HEADERS symbol which has changed behavior by commit https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=64029e93683a266c38d19789e780f3748bd6a188 which result in situation that program headers has changed from (xilinx_zynqmp_mini_defconfig) Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000010000 0x00000000fffc0000 0x00000000fffc0000 0x0000000000018918 0x0000000000018918 RW 0x10000 to Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x00000000fffb0000 0x00000000fffb0000 0x0000000000028918 0x0000000000028918 RW 0x10000 Xilinx tools like XSDB or Bootgen are using program headers for loading ELF to the right location and by above binutils change ELF is loaded to incorrect location. The patch is explicitly use u-boot-elf.lds (just cat now) for u-boot.elf recreation which is called when REMAKE_ELF is setup. By purpose u-boot-elf.lds doesn't contain OUTPUT_FORMAT/OUTPUT_ARCH to be able to use by all archs. Signed-off-by: Michal Simek --- Sadanand, Mahesh: Please correct my description if I am wrong based on our internal discussion about this issue. Tom: I have been told that it is GCC issue but I found that commit in binutils. I am not doing these makefile stuff that's why I expect this should be changed a little bit. Also arch/u-boot-elf.lds is likely incorrect location but didn't find any better. --- Makefile | 7 +++++-- arch/u-boot-elf.lds | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 arch/u-boot-elf.lds diff --git a/Makefile b/Makefile index be1513227361..410cfb3fcb2e 100644 --- a/Makefile +++ b/Makefile @@ -1654,12 +1654,15 @@ ifndef PLATFORM_ELFENTRY endif quiet_cmd_u-boot-elf ?= LD $@ cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ - --defsym=$(PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \ + -T u-boot-elf.lds --defsym=$(PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) -u-boot.elf: u-boot.bin +u-boot.elf: u-boot.bin u-boot-elf.lds $(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o $(call if_changed,u-boot-elf) +u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE + $(call if_changed,cat) + # MediaTek's ARM-based u-boot needs a header to contains its load address # which is parsed by the BootROM. # If the SPL build is enabled, the header will be added to the spl binary, diff --git a/arch/u-boot-elf.lds b/arch/u-boot-elf.lds new file mode 100644 index 000000000000..1939d7f81c25 --- /dev/null +++ b/arch/u-boot-elf.lds @@ -0,0 +1,9 @@ +ENTRY(_start) +SECTIONS +{ + . = _start; + + .data : { + *(.data*) + } +}