From nobody Sun May 5 00:27:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+51000+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51000+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1574321564; cv=none; d=zoho.com; s=zohoarc; b=XPWdPtr/Uu/mmz6ubAcp/DcvkmSjJiXQSg4VY3iHLBzMs5lVsHTW3e6HiWdCcunOvEXb9bUOAJckTsMdbPK0IB1YqDdAfZcWZB4qHXHXZcoAy655dDfhG9i1BNVowhBDgIadwhfOsRrhSmqYNbbTqiznM9ERaCgEVt0XeVOswpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574321564; h=Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=3gCo+zpi04hSM3mFI9yEZUQPiAvb69ZlFN7pZ60lQ1Y=; b=V8udJ9vRYJG2pzHNWIzar+ZcOXLSveLWdqPH2kU1M2xNRxXcDSwKCJmnmfKaUvHS3fYx0In/pvaSyNBgfTm256v55oMvoGPyCTGFRvnlB+mJ0nD+ciTcNK2U+PIDWt71bFuShjKKVr8yzx8iClhYMnheqDSdc9YlX0FcJgyPc+Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51000+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1574321564474498.4171404839991; Wed, 20 Nov 2019 23:32:44 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Wed, 20 Nov 2019 23:32:43 -0800 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.20752.1574321562280910834 for ; Wed, 20 Nov 2019 23:32:42 -0800 X-Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAL7W0XC018449; Thu, 21 Nov 2019 07:32:41 GMT X-Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 2wdghbja5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2019 07:32:41 +0000 X-Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 7CF76AF; Thu, 21 Nov 2019 07:32:40 +0000 (UTC) X-Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 8E9473B; Thu, 21 Nov 2019 07:32:38 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com, Bob Feng , Liming Gao , Leif Lindholm , Gilbert Chen Subject: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3-2] BaseTools: Fix edk2 RISC-V binary hangs at POST with the latest toolchain Date: Thu, 21 Nov 2019 14:59:54 +0800 Message-Id: <1574319594-18258-1-git-send-email-abner.chang@hpe.com> X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1574321563; bh=lOf4SFUN+wMtndsqi0QFf6PFrr27w0aVm9dENsrDd7M=; h=Cc:Date:From:Reply-To:Subject:To; b=iqe5nY364obWUzdLksMFxqSUbXWK9VWYnqIdkreiugtaNQjdi77RS44oLyXYvJ2M77m asq+fousKpn34iiHo8tbJiOp7U+ndu+kaS4Md1XseAtoKQgIhknvurB8gAhQVqfaEAMkD 3izcXwhB3Lpdg9H8bkU2vXQj5hXG3Af41fE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit fixes the edk2 RISC-V binary hangs at early POST with latest riscv-gnu-toolchain issue. - Add compiler option -msmall-data-limit=3D0 to disable small data is placed in .sdata2 section which causes the relocation is not fixed in correctly on edk2 build tool. - Remove GccBaseRiscV.lds, the GccBase.lds works fine with latest toolchain. Signed-off-by: Abner Chang Cc: Bob Feng Cc: Liming Gao Cc: Leif Lindholm Cc: Gilbert Chen --- RiscVEdk2Readme.md | 14 ++----- BaseTools/Conf/tools_def.template | 7 ++-- BaseTools/Scripts/GccBaseRiscV.lds | 79 ----------------------------------= ---- 3 files changed, 6 insertions(+), 94 deletions(-) delete mode 100644 BaseTools/Scripts/GccBaseRiscV.lds diff --git a/RiscVEdk2Readme.md b/RiscVEdk2Readme.md index ebd7495..6136905 100644 --- a/RiscVEdk2Readme.md +++ b/RiscVEdk2Readme.md @@ -32,21 +32,13 @@ RiscVPlatformPkg - RISC-V platform package. This packa= ge provides RISC-V platform common modules, libraries, PCDs and definitoi= ns. ``` ## Toolchain of RISC-V EDK2 port -Due to not yet tracked down bugs, only the following toolchain is known to -produce bootoable binaries. -https://github.com/riscv/riscv-gnu-toolchain at commit ID 64879b24. -The commit ID 64879b24 of riscv-gnu-toolchain repository is verified to bu= ild -RISC-V edk2 platform and boot to EFI SHELL successfully. -You have to clone the toolchain from above link and check out commit:64879= b24 -for building RISC-V edk2 port. -The commit later than 64879b24 causes system hangs at the PEI phase to DXE= phase -transition. We are still figuring out the root cause. +https://github.com/riscv/riscv-gnu-toolchain +You have to clone the toolchain from above link for building RISC-V edk2 p= ort. =20 ## EDK2 Build Target "RISCV64" ARCH is the RISC-V architecture which currently supported and ve= rified. The verified RISC-V toolchain is https://github.com/riscv/riscv-gnu-toolch= ain -@64879b24 as mentioned above, toolchain tag is "GCC5" which is declared in -tools_def.txt. +and the toolchain tag is "GCC5" which is declared in tools_def.txt. Below is the edk2 build options for building RISC-V RV64 platform, ``` build -a RISCV64 -p Platform/{Vendor}/{Platform}/{Platform}.dsc -t GCC5 diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 8adfab0..2fa85ba 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -1808,17 +1808,16 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS =3D DEF(GCC49_= ARM_ASLDLINK_FLAGS) DEFINE GCC5_AARCH64_ASLDLINK_FLAGS =3D DEF(GCC49_AARCH64_ASLDLINK_FLAGS) DEFINE GCC5_ASLCC_FLAGS =3D DEF(GCC49_ASLCC_FLAGS) -fno-lto =20 -DEFINE GCC5_RISCV_ALL_CC_FLAGS =3D -g -fshort-wchar -fn= o-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdat= a-sections -c -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=3D$(BASE_N= AME)Strings +DEFINE GCC5_RISCV_ALL_CC_FLAGS =3D -g -fshort-wchar -fn= o-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdat= a-sections -c -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=3D$(BASE_N= AME)Strings -msmall-data-limit=3D0 DEFINE GCC5_RISCV_ALL_DLINK_COMMON =3D -nostdlib -n -q --gc= -sections -z common-page-size=3D0x40 DEFINE GCC5_RISCV_ALL_DLINK_FLAGS =3D DEF(GCC5_RISCV_ALL_D= LINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DE= ST_DIR_DEBUG)/$(BASE_NAME).map -DEFINE GCC5_RISCV_ALL_DLINK2_FLAGS =3D --defsym=3DPECOFF_HE= ADER_SIZE=3D0x220 --script=3D$(EDK_TOOLS_PATH)/Scripts/GccBaseRiscV.lds +DEFINE GCC5_RISCV_ALL_DLINK2_FLAGS =3D --defsym=3DPECOFF_HE= ADER_SIZE=3D0x220 --script=3D$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC5_RISCV_ALL_ASM_FLAGS =3D -c -x assembler -ima= cros $(DEST_DIR_DEBUG)/AutoGen.h DEFINE GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE =3D -Wno-tautological-co= mpare -Wno-pointer-compare =20 DEFINE GCC5_RISCV64_ARCH =3D rv64imafdc DEFINE GCC5_RISCV32_RISCV64_ASLDLINK_FLAGS =3D DEF(GCC5_RISCV_ALL_DLINK_CO= MMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable -DEFINE GCC5_RISCV32_RISCV64_DLINK_FLAGS =3D DEF(GCC5_RISCV_ALL_DLINK_CO= MMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_= DEBUG)/$(BASE_NAME).map -DEFINE GCC5_RISCV64_CC_FLAGS =3D DEF(GCC5_RISCV_ALL_CC_FLAGS= ) DEF(GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE) -march=3DDEF(GCC5_RISCV64_AR= CH) -fno-builtin -fno-builtin-memcpy -fno-stack-protector -Wno-address -fno= -asynchronous-unwind-tables -Wno-unused-but-set-variable -fpack-struct=3D8 = -mcmodel=3Dmedany -mabi=3Dlp64 +DEFINE GCC5_RISCV64_CC_FLAGS =3D DEF(GCC5_RISCV_ALL_CC_FLAGS= ) DEF(GCC5_RISCV_ALL_CC_FLAGS_WARNING_DISABLE) -march=3DDEF(GCC5_RISCV64_AR= CH) -fno-builtin -fno-builtin-memcpy -fno-stack-protector -Wno-address -fno= -asynchronous-unwind-tables -Wno-unused-but-set-variable -fpack-struct=3D8 = -mcmodel=3Dmedany -mabi=3Dlp64 -mno-relax DEFINE GCC5_RISCV64_DLINK_FLAGS =3D DEF(GCC5_RISCV_ALL_DLINK_FL= AGS) -melf64lriscv --oformat=3Delf64-littleriscv --no-relax DEFINE GCC5_RISCV64_DLINK2_FLAGS =3D DEF(GCC5_RISCV_ALL_DLINK2_F= LAGS) DEFINE GCC5_ASM_FLAGS =3D DEF(GCC5_RISCV_ALL_ASM_FLAG= S) -march=3DDEF(GCC5_RISCV64_ARCH) -mcmodel=3Dmedany -mabi=3Dlp64 diff --git a/BaseTools/Scripts/GccBaseRiscV.lds b/BaseTools/Scripts/GccBase= RiscV.lds deleted file mode 100644 index 91937aa..0000000 --- a/BaseTools/Scripts/GccBaseRiscV.lds +++ /dev/null @@ -1,79 +0,0 @@ -/** @file - - Unified linker script for GCC based builds - - Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
- Copyright (c) 2015, Linaro Ltd. All rights reserved.
- Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All right= s reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -SECTIONS { - - /* - * The PE/COFF binary consists of DOS and PE/COFF headers, and a sequenc= e of - * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs - * between 32-bit and 64-bit builds). The actual start of the .text sect= ion - * will be rounded up based on its actual alignment. - */ - . =3D PECOFF_HEADER_SIZE; - - .text : ALIGN(CONSTANT(COMMONPAGESIZE)) { - *(.text .text.* .stub .gnu.linkonce.t.*) - *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.got .got.*) - - /* - * The contents of AutoGen.c files are mostly constant from the POV of= the - * program, but most of it ends up in .data or .bss by default since f= ew of - * the variable definitions that get emitted are declared as CONST. - * Unfortunately, we cannot pull it into the .text section entirely, s= ince - * patchable PCDs are also emitted here, but we can at least move all = of the - * emitted GUIDs here. - */ - *:AutoGen.obj(.data.g*Guid) - } - - /* - * The alignment of the .data section should be less than or equal to the - * alignment of the .text section. This ensures that the relative offset - * between these sections is the same in the ELF and the PE/COFF version= s of - * this binary. - */ - .data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) { - *(.data .data.* .gnu.linkonce.d.*) - *(.bss .bss.*) - } - - .eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : { - KEEP (*(.eh_frame)) - } - - .rela ALIGN(CONSTANT(COMMONPAGESIZE)) : { - *(.rela .rela.*) - } - - .hii : ALIGN(CONSTANT(COMMONPAGESIZE)) { - KEEP (*(.hii)) - } - - /* - * Retain the GNU build id but in a non-allocatable section so GenFw - * does not copy it into the PE/COFF image. - */ - .build-id (INFO) : { *(.note.gnu.build-id) } - - /DISCARD/ : { - *(.note.GNU-stack) - *(.gnu_debuglink) - *(.interp) - *(.dynsym) - *(.dynstr) - *(.dynamic) - *(.hash .gnu.hash) - *(.comment) - *(COMMON) - } -} --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51000): https://edk2.groups.io/g/devel/message/51000 Mute This Topic: https://groups.io/mt/61064646/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-