From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.441.1574187476543126353 for ; Tue, 19 Nov 2019 10:17:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SvDz7ZTW; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: msalter@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574187475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Na8PxB6enlsSHLU/UKaRsdhuuHLsrAPsb3IfPBK4c2c=; b=SvDz7ZTW7hVfYJbWYDkLjXForIgJSTAlxM3RczrtUQhj3dlqVYUvJb1iEJMYShNQJ77jn7 BFRI116Psi118+jrLPEqYhylHpvHQkEwwpQS9l8MWkDPDJGXqNs1l5a2iDtpV+qC46VePM 9zYYpUEzU2pKZpzKTHXWq9YyT3h8uo8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-r2SL9rU-MkqHGlcaC2lVOA-1; Tue, 19 Nov 2019 13:17:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7D3F1051C32; Tue, 19 Nov 2019 18:17:51 +0000 (UTC) Received: from ovpn-124-164.rdu2.redhat.com (ovpn-124-164.rdu2.redhat.com [10.10.124.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 085F65D6BB; Tue, 19 Nov 2019 18:17:50 +0000 (UTC) Message-ID: Subject: Re: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3 25/39] BaseTools/Scripts From: "Mark Salter" To: devel@edk2.groups.io, abner.chang@hpe.com Cc: Bob Feng , Liming Gao , Leif Lindholm , Gilbert Chen Date: Tue, 19 Nov 2019 13:17:50 -0500 In-Reply-To: <1572227957-13169-26-git-send-email-abner.chang@hpe.com> References: <1572227957-13169-1-git-send-email-abner.chang@hpe.com> <1572227957-13169-26-git-send-email-abner.chang@hpe.com> Organization: Red Hat, Inc User-Agent: Evolution 3.34.1 (3.34.1-1.fc31) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: r2SL9rU-MkqHGlcaC2lVOA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 2019-10-28 at 09:59 +0800, Abner Chang wrote: > Add RISC-V specific LD scripts. ."rela(INFO)" in the latest GccBase.lds > causes PE32 relocation error. > This is the temporaty solution untill we find the root casue. >=20 > Signed-off-by: Abner Chang >=20 > Cc: Bob Feng > Cc: Liming Gao > Cc: Leif Lindholm > Cc: Gilbert Chen > --- > BaseTools/Scripts/GccBaseRiscV.lds | 79 ++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 79 insertions(+) > create mode 100644 BaseTools/Scripts/GccBaseRiscV.lds >=20 > diff --git a/BaseTools/Scripts/GccBaseRiscV.lds b/BaseTools/Scripts/GccBa= seRiscV.lds > new file mode 100644 > index 0000000..91937aa > --- /dev/null > +++ b/BaseTools/Scripts/GccBaseRiscV.lds > @@ -0,0 +1,79 @@ > +/** @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 rig= hts reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +SECTIONS { > + > + /* > + * The PE/COFF binary consists of DOS and PE/COFF headers, and a seque= nce of > + * section headers adding up to PECOFF_HEADER_SIZE bytes (which differ= s > + * between 32-bit and 64-bit builds). The actual start of the .text se= ction > + * 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.*) So, I tried running this risc-v port on a HiFive Unleashed board but it crashed pretty early on. It turned out that the linker was placing some const data at the start of .text before any actual code. That didn't work out well. I got around that and was able to boot into the efi shell by adding this to tell the linker explicitly where to put that data: *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) > + *(.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= few of > + * the variable definitions that get emitted are declared as CONST. > + * Unfortunately, we cannot pull it into the .text section entirely,= since > + * patchable PCDs are also emitted here, but we can at least move al= l 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 offs= et > + * between these sections is the same in the ELF and the PE/COFF versi= ons 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) > + } > +}