From patchwork Mon Mar 30 11:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1263906 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=e9DcQ+4g; 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 48rWGJ73Dtz9sPR for ; Mon, 30 Mar 2020 22:59:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69C1E8065F; Mon, 30 Mar 2020 13:59:12 +0200 (CEST) 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="e9DcQ+4g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B261B8019A; Mon, 30 Mar 2020 13:59: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,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 02D078019A for ; Mon, 30 Mar 2020 13:59:05 +0200 (CEST) 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-wm1-x342.google.com with SMTP id z14so2993667wmf.0 for ; Mon, 30 Mar 2020 04:59:05 -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=5JARf5Si+jVJNl/chEj7yakp42JbL4JZGA/UGw3wUQ8=; b=e9DcQ+4gsKPGz7nMMv1Sy5q8hzd7w0Frdo8aYPKGl+QPi83AGeVAJ8Ca1hF9zSwKkS LroLasCK+Bcc/6bAOeexi4daL3zBGctJCi5j0AQxU0l0AplJV2BvSPamVzAT5c7C6N1a 6DyTAWSGaL8O9Bp9TktRx9/3ljlcEKEMY6NllwjqMZ9kYu3Ap6BHNgvivegQl13Dm0h6 69aj/psIaaH6xCrA4x9ERowaTZifmukehBH4gUdanlhlE5zixLyzpeKNUe/HLJoAuzjO A4a+XuBV6OygtE3FKE3DbvjLSVUGGEqnJ4FIuOiq2jS6VAssKpr513T/c1VDEkD9SPM8 DhCg== 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=5JARf5Si+jVJNl/chEj7yakp42JbL4JZGA/UGw3wUQ8=; b=gqv+cAH5Ay0kC816hnwQWgGgkoVRwsbZwfNRlt/jzH66MY+78yCo9+7cGBuh7DgKcK pK5yJx0I2lP8Kcnc1nnLJsoGFyVIbPZjuMgw6JdS3PWFEValQg4GeZyIehSP1eVoo/wq Yu3Q3SW/kkXY30jBIKJQw58tdU+jXwEpNQ7KuBiJzF1Xx9g/2wyBT/GtgLQtv9Yrm5vF nCPTsSz30lrFDIIzYqCSHo3H9RqEmLdVHuCmGMAFHyL90yOrWsNCldBDueSlz6KPw1vJ B7ULQZEYHxgoIj7HPPTYRdtPN4dX3Vj9FRcYiaCIV6ulP1w6mU/mn3l4Cn08U90K6+hm dsVw== X-Gm-Message-State: ANhLgQ2kE7kba5UBMznKYT9Z7obr4OoyI6XcL0uHs+zGjepeUg2lrKd7 ojeB1vSgH7zhdfKb3MXB1Iq35bUEp+qCkg== X-Google-Smtp-Source: ADFU+vuDlygdYxjTa6AqUCsZZTivvrbFtcvwcngpvF8XLx8Rc2HMS7Fth3gmU10aqhPklaN6AtRA/w== X-Received: by 2002:a7b:c359:: with SMTP id l25mr13102248wmj.149.1585569544806; Mon, 30 Mar 2020 04:59:04 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id a73sm20608744wme.47.2020.03.30.04.59.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Mar 2020 04:59:04 -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: Adam Ford , Bin Meng , Daniel Schwierzeck , Fabio Estevam , Heinrich Schuchardt , Jagan Teki , Jean-Jacques Hiblot , Kever Yang , Marek Vasut , Simon Glass , Simon Goldschmidt , Stefan Roese Subject: [PATCH v2] arch: Add explicit linker script for u-boot-elf Date: Mon, 30 Mar 2020 13:58:59 +0200 Message-Id: X-Mailer: git-send-email 2.26.0 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 Reviewed-by: Tom Rini Reviewed-by: Daniel Schwierzeck Tested-By: Álvaro Fernández Rojas --- Changes in v2: - Use preprocessor and Kconfig entry for passing different PLATFORM_ENTRY Suggested-by: Daniel Schwierzeck - I kept u-boot.elf.lds in origin location because most of lds are in arch/ folder Changes in v1: - Compare to RFC - MIPS has different elf entry point that's why I replaced simple cat with sed to setup proper entry point 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. --- Kconfig | 5 +++++ Makefile | 11 +++++------ arch/mips/config.mk | 1 - arch/u-boot-elf.lds | 9 +++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 arch/u-boot-elf.lds diff --git a/Kconfig b/Kconfig index 66148ce47790..dc23c35000f2 100644 --- a/Kconfig +++ b/Kconfig @@ -298,6 +298,11 @@ config ERR_PTR_OFFSET pointer values - up to 'MAX_ERRNO' bytes below this value must be unused/invalid addresses. +config PLATFORM_ELFENTRY + string + default "__start" if MIPS + default "_start" + endmenu # General setup menu "Boot images" diff --git a/Makefile b/Makefile index be1513227361..c1dc185e5c0e 100644 --- a/Makefile +++ b/Makefile @@ -1648,18 +1648,17 @@ OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \ u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE $(call if_changed,pad_cat) -# Create a new ELF from a raw binary file. -ifndef PLATFORM_ELFENTRY - PLATFORM_ELFENTRY = "_start" -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=$(CONFIG_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_dep,cpp_lds) + # 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/mips/config.mk b/arch/mips/config.mk index 9d3a84539a7d..527fd6a2fd92 100644 --- a/arch/mips/config.mk +++ b/arch/mips/config.mk @@ -36,7 +36,6 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 endif PLATFORM_CPPFLAGS += -D__MIPS__ -PLATFORM_ELFENTRY = "__start" PLATFORM_ELFFLAGS += -B mips $(OBJCOPYFLAGS) # diff --git a/arch/u-boot-elf.lds b/arch/u-boot-elf.lds new file mode 100644 index 000000000000..1666027e3635 --- /dev/null +++ b/arch/u-boot-elf.lds @@ -0,0 +1,9 @@ +ENTRY(CONFIG_PLATFORM_ELFENTRY) +SECTIONS +{ + . = CONFIG_PLATFORM_ELFENTRY; + + .data : { + *(.data*) + } +}