From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.3866.1649410738334557702 for ; Fri, 08 Apr 2022 02:38:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=MuRGqRmw; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0097613c5e=abner.chang@hpe.com) Received: from pps.filterd (m0134425.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2383VvUD004477; Fri, 8 Apr 2022 09:38:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=6D4ix9njQsbIZvO47WOyKYT/3aud5tzVAW1fCBfI/mY=; b=MuRGqRmwK44boUGIM7KNhdLYI25IoJUk0FSOmwsgaB5S3LRQ0EPU15Q9Bn1m/d8jQLY0 d0Wu178QzxhaXocrMsM6GLHTc/8dIfpiEyyGUP8MZWgO/EtUlxqviu2D1+o/Cygugnbl j0OikDzeyxw6aq+QePHLibllqukt/VkSPhpgPZuod5SLsdrmPnX4GsF9xnem5hBgsO1r CT3kVOOj83AR9STpvxegq10HWzYHwJrPziNJ5kvDf6SanGWZyJ6ntrah2fYrfdrYglfo bgZKMAMn9i4zloZDBeMLK1SofPWby7nJkYuC86rwjtQG3SVenjm9uXC8bB8+s+Xi9Ebr cw== Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3fa28pfq30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Apr 2022 09:38:52 +0000 Received: from p1wg14924.americas.hpqcorp.net (unknown [10.119.18.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id A928F131A1; Fri, 8 Apr 2022 09:38:51 +0000 (UTC) Received: from p1wg14924.americas.hpqcorp.net (10.119.18.113) by p1wg14924.americas.hpqcorp.net (10.119.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Thu, 7 Apr 2022 21:38:51 -1200 Received: from P1WG14918.americas.hpqcorp.net (16.230.19.121) by p1wg14924.americas.hpqcorp.net (10.119.18.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15 via Frontend Transport; Thu, 7 Apr 2022 21:38:51 -1200 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (192.58.206.38) by edge.it.hpe.com (16.230.19.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Fri, 8 Apr 2022 09:38:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mdkoBZ8/Bp6jR5OZYcvutM6e4Qk3avSFWT4dU5fpZydC7aViCPnujkWIl+dYUC2hKDpeLc1bbhysYodsy1J0jlNukDpWYTrLon4oG1zqKSn/h5ziTGYjILdVW1E3zjfezWeKxt7GNyBz/zzFkuzEUWb04pZpSeTwxzvcK4baEkJELEve6co0Jy5J9wkNMXqaZxJIIFOJShFsWr8By4RS2zDKZzPpeB5uRL1sdTElUHIekI8QqccsttkLSXJR+4UENABQzJcNjtS5WSGBzWeNyyYTNnUV7/0JMi2HMs4NwQyeCKH0tJHpkUxbWWyDc8M8FL9KjWqT8V/DwQgTqJPv8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7luFSqe5bUQ2JmfkR5pIa1jR+hu4urdMtuVanm9x4z8=; b=JRYemO7aKZ+Q0ZOeFkAOkOWfcNw0oS8BCO6IKcqnbMUwrkhnfvknPHeO8+hJKm1B338SHtE3fay9YugWwz+H4avL3LdjjcftGa2P3BeKVmgXtGOUMxpXCPjtHBMBlfBGLKSw3hXfddxFswupFE2Xzzu34DNjXgsQZzLf8AGsRXmlkx8kh3KSbHdpDJWUQQcZNPAkNQfb2BjSOGiqhWc1olY10XLnN9UUbGG28mr6iakwypCcaudgQesDsP33f0J9aZMGOgXBWmjKRTXC3uS03wi1EJZwayvFh1CvgD4zM+OyywJUHAlmJCTwRWXxa4kMWvZ7CgzDPm5lRNTHa/tsaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:154::18) by MW4PR84MB1659.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.26; Fri, 8 Apr 2022 09:38:48 +0000 Received: from PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM ([fe80::2053:811f:bd4a:7c21]) by PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM ([fe80::2053:811f:bd4a:7c21%8]) with mapi id 15.20.5144.022; Fri, 8 Apr 2022 09:38:48 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "lichao@loongson.cn" CC: Michael D Kinney , Liming Gao , Zhiguang Liu , "Baoqi Zhang" Subject: Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. Thread-Topic: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. Thread-Index: AQHYHYI8mh30CyMXwkq4fJdUNgAo7KzmHWfQ Date: Fri, 8 Apr 2022 09:38:48 +0000 Message-ID: References: <20220209065600.2989284-1-lichao@loongson.cn> In-Reply-To: <20220209065600.2989284-1-lichao@loongson.cn> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 47b26b40-eff0-4d24-2c36-08da19439546 x-ms-traffictypediagnostic: MW4PR84MB1659:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: z/CB3FtQ3WUyLaMY/bJLAsDfm9UQEu01ZgEWqHZ2O7NKOrTh1nhJ85bEO3bL6NzfsbCE/b1u1Ov8pEDdembMvbpXwrU6mkc995vRKnQbtwPNYbQ4+7XHuBLh6gPcF9tU8F2Bau7fx1Iv0emZkecJI3XS4NXnHH6t5ytGGFtM7e9gNVRjxoJus37Fc6Zhf9Jw839vKuvCHpV2cx6Yk2VRaOuzFwpSUnwLcpYc+rU30heylvCHK6aoFYwe/VqjKGPng1FOnr/N0epMVrYfWeTd6+W+tAtXqX7TYiJwxHqaz2eY3plg7N2o+XoZagQLKA9K52kksRYkv65Cnl6H8rfROiOl3E25HLHtvLs5WYLbxGIqhgBmpC9dzi+GKkhtESB1fhbK21QlPbisFz5WHpLNDb7SouEbz1wA6mlx7lsKUS3TEgtMU06b1Ey6z6JH2bFq1kFC9X1z8SsQLU/pVrx4zaKdDGGGu2K+z658+mNSAQ0bODHRMFefpjbrrqemqg6BK0HTre7G2G+pCAVam3mLbs+SAvF5QosnBtETpwF16Q5LBA608P+cjTL+oBbpmd1AwXuhg9KujcdNfk5woOInOik0PF3CCm92zGQJQFUW8bzp8iTA4E1ir5uYmgO83w7vBmD6QOVKU8lrIsYa+zCyvcIKAWyBu30ukTQvL44M/xIvuTRXoOKUmm/AlyVPzniph/JMWANoAGDj5VV9AaNmLFgKKloeynw+JW6QEsVN00llnkXUNUbDSuYXl/nQyEhJizHfRkJVBtZZw+BB/kKh7lyeiynNozn4XnOTtm2J4yVTUEXx6K98u8LdkIKQKCCgwMaNsMYegViqB5W5cXynmA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(6029001)(366004)(66946007)(38070700005)(66446008)(66476007)(64756008)(76116006)(966005)(508600001)(55016003)(66556008)(4326008)(8676002)(54906003)(316002)(110136005)(71200400001)(33656002)(86362001)(83380400001)(9686003)(38100700002)(122000001)(53546011)(6506007)(7696005)(186003)(26005)(82960400001)(8936002)(2906002)(52536014)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?W8BpqLxdvYcfQftpEFyndd/NsJb8ROZlBdbAWZiFV6NBdmyKHOIT2I8hbPm8?= =?us-ascii?Q?u8HbSEfLVMN+0Wv5sZzasQBRBW8brIq0IWCtuV8/LIgQhxbBZlDnwMPnBIXQ?= =?us-ascii?Q?8PCVd8en9KcC28klqgF3kkfK/k976YtfmEoWJsJsTF8eH93agyiEDndpgHLj?= =?us-ascii?Q?I6A+krsG+Dqhy+KVtv8b/mxpEV9RyTMkdX9Yo6fZ9FcwmSVHrymwES5Xa0o6?= =?us-ascii?Q?FZIV4JAbVUQPB6XgVZEy0Kou/lnQqp129AgKvW+V6dkSQ4uGTP/trVn0csBD?= =?us-ascii?Q?X8muH4ML4rcTMy6Hdss3uclYlVAFQrcBfXGQx+PZcFy8Ys8GUSliBrcQVNdn?= =?us-ascii?Q?iVXM7NdogjWqf1gO2WRG1YUgcTkwfnHgItHakCT+5DLpuWzt5WPj0NoAmCG6?= =?us-ascii?Q?hdwfHvnA6VzH1APvItM6vvT+xOFQBlJ6qN9C4aYLllv0k2ji0VIF/KXB9w9S?= =?us-ascii?Q?jROCipvLjpc5vA3bBe3RoccA53wHljg5CiYSFLSRHW0mtq5j82K4ATWQ7XZA?= =?us-ascii?Q?1xgSWPRpNjEzEfwslVcQ10umAuEAR05u33VU8/FRtKcP+wFgplqA7LImQaaX?= =?us-ascii?Q?mmFZor4WOaI8PwP8r3hhfVVMzp9EwlHV9SzagMkd7K/e6+0Uv1/cie+hU5Vz?= =?us-ascii?Q?MtaUcHhFFXqBrDs/9VMPDTMUEBxVuLPE1ypqjREpoJlAxk25pjQyTUBRc5tg?= =?us-ascii?Q?0n8MTHrZ60M1nLvbpefYkDWIke/rvByLYAt5QVUdX8HhWLT1gKwNTK/uCmSb?= =?us-ascii?Q?PvIpcOsJgSMCPPYwJg1+ymrp6RWkT0YUGdpnyL1tm6cuLNR0X4PpBPsvLXN3?= =?us-ascii?Q?EZ2t/cT0xUqdlPCx5T+cNnNbOUmutEq/tRjeIl+9lpnNAdJ4MAIr6xxgyGPK?= =?us-ascii?Q?NI901yQAFKbp3FL1Xba1lY+HcU0OIluZyNyNiV3PnLXeBJoN8Ok27pze2lo1?= =?us-ascii?Q?FzNjTw/ppYJfoFxdQr1XNM1fFY+ywTsheNCiwaKHgtPkMi0IFuD84G8RSYHf?= =?us-ascii?Q?J45M84NDEVqvR038OJxtIiEV1Svb+FYREF0buNtNTsz+RiqdYx9t5sts6FBw?= =?us-ascii?Q?DWRrJ/fGbaruNmeUkmta4yaWVnSSuoqOF/C8GbI/TA4Mex16mHvZcLdx3/y5?= =?us-ascii?Q?UCtyQdnU476W0oUcUt5eX6TbOiFELqgzlUuYVKCbV2zyGDKJ5qBZ6NmPa+Cj?= =?us-ascii?Q?yD/Ut7kyjKoVm6dgq8Wxkjz3vnyu+e1G7hUP68UObheZMeLp+APsH98TVtlq?= =?us-ascii?Q?dzRxwvh6zqIdqRwCYnuNmrWtQEsGjBSY4qQkbEX7y/HFyv5eyPF74pjSqRNv?= =?us-ascii?Q?xOZt6VQDiD+lBl1TqB0X4Twnd/5QZ+x0gngmSzTQGMSRCAOI8XnBYov3jWLK?= =?us-ascii?Q?Jxc1GxxleBx8rNKGiX0LNQbx82/vW54mJAeY/R4fAQ5agB/GaHre+bCK692F?= =?us-ascii?Q?wT+EdRdv/ho/W8stx2HeouPELVcGEu5VhOHR2ydLBfU+3hsVD6CzCtcqCQ9s?= =?us-ascii?Q?Q+LmGnRwbxBUen8mH/HQ+a7xwKjtA8z9b9CE0LHm0g+mIIPjbNAnwTT8xnvV?= =?us-ascii?Q?HfoBBoGNloPQQsYlJPlBDUySB+hbrvB4lk6Yh1dRrfha/X3wdx5vbd18nFi7?= =?us-ascii?Q?12Jc3u6n5zwFsq0qh//YQrDBtuKni1lGgN7lQogLkSsZHiwbPf6FkSSRiLzG?= =?us-ascii?Q?5w6K71334pRhepGjJtmiasi0KvpLFtSsb5lGBOuCuOKxWtJFF6fcuc8g7bD6?= =?us-ascii?Q?N6EWfVrOuA=3D=3D?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 47b26b40-eff0-4d24-2c36-08da19439546 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2022 09:38:48.2690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: I+lMdr7NFnqND2nprtDgeq7DFYDWWy7btjOcwBgfzbT0drN3lXHZ2x2dne8gR+lRAHVJq7HHoujfEIdLQtLw8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR84MB1659 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: Sg4yJEvDGckKC_R6JF93SJLeRoRw4lSB X-Proofpoint-ORIG-GUID: Sg4yJEvDGckKC_R6JF93SJLeRoRw4lSB X-Proofpoint-UnRewURL: 2 URL's were un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-08_03,2022-04-07_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 adultscore=0 mlxlogscore=669 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204080050 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chao Li > Sent: Wednesday, February 9, 2022 2:56 PM > To: devel@edk2.groups.io > Cc: Michael D Kinney ; Liming Gao > ; Zhiguang Liu ; Baoqi > Zhang > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] > MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. >=20 > Add LoongArch image relocation. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu >=20 > Signed-off-by: Chao Li > Co-authored-by: Baoqi Zhang > --- > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 3 +- > .../Library/BasePeCoffLib/BasePeCoffLib.inf | 5 + > .../Library/BasePeCoffLib/BasePeCoffLib.uni | 2 + > .../BasePeCoffLib/LoongArch/PeCoffLoaderEx.c | 132 > ++++++++++++++++++ > 4 files changed, 141 insertions(+), 1 deletion(-) > create mode 100644 > MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c >=20 > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > index 6d8d9faeb8..97a8aaf8c7 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > @@ -1,6 +1,6 @@ > /** @file > Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but > - only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC images. > + only supports relocating IA32, x64, IPF, ARM, RISC-V, LoongArch and EB= C > images. >=20 > Caution: This file requires additional review when modified. > This library will have external input - PE/COFF image. > @@ -18,6 +18,7 @@ > Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP= . > All rights reserved.
> + Portions Copyright (c) 2022, Loongson Technology Corporation Limited. = All > rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > index 110b6d5a09..3b8b8eb191 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf > @@ -4,6 +4,7 @@ > # The IA32 version library support loading IA32, X64 and EBC PE/COFF im= ages. > # The X64 version library support loading IA32, X64 and EBC PE/COFF ima= ges. > # The RISC-V version library support loading RISC-V images. > +# The LoongArch version library support loading LoongArch images. > # > # Caution: This module requires additional review when modified. > # This library will have external input - PE/COFF image. > @@ -13,6 +14,7 @@ > # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > # Portions Copyright (c) 2020, Hewlett Packard Enterprise Development L= P. > All rights reserved.
> +# Portions Copyright (c) 2022, Loongson Technology Corporation Limited.= All > rights reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -46,6 +48,9 @@ > [Sources.RISCV64] > RiscV/PeCoffLoaderEx.c >=20 > +[Sources.LOONGARCH64] > + LoongArch/PeCoffLoaderEx.c > + > [Packages] > MdePkg/MdePkg.dec >=20 > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > index 55417029f2..1f731344e1 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni > @@ -5,6 +5,7 @@ > // The IA32 version library support loading IA32, X64 and EBC PE/COFF > images. > // The X64 version library support loading IA32, X64 and EBC PE/COFF ima= ges. > // The RISC-V version library support loading RISC-V32 and RISC-V64 PE/C= OFF > images. > +// The LoongArch version library support loading LoongArch32 and > LoongArch64 PE/COFF images. > // > // Caution: This module requires additional review when modified. > // This library will have external input - PE/COFF image. > @@ -14,6 +15,7 @@ > // Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. > // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > // Portions Copyright (c) 2020, Hewlett Packard Enterprise Development L= P. > All rights reserved.
> +// Portions Copyright (c) 2022, Loongson Technology Corporation Limited. > All rights reserved.
> // > // SPDX-License-Identifier: BSD-2-Clause-Patent > // > diff --git a/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > new file mode 100644 > index 0000000000..ec572c2dd6 > --- /dev/null > +++ b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c > @@ -0,0 +1,132 @@ > +/** @file > + PE/Coff loader for LoongArch PE image > + > + Copyright (c) 2022, Loongson Technology Corporation Limited. All right= s > reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include "BasePeCoffLibInternals.h" > +#include > + > +/** > + Performs an LoongArch specific relocation fixup and is a no-op on othe= r > + instruction sets. > + > + @param Reloc Pointer to the relocation record. > + @param Fixup Pointer to the address to fix up. > + @param FixupData Pointer to a buffer to log the fixups. > + @param Adjust The offset to adjust the fixup. > + > + @return Status code. > + > +**/ > +RETURN_STATUS > +PeCoffLoaderRelocateImageEx ( > + IN UINT16 *Reloc, > + IN OUT CHAR8 *Fixup, > + IN OUT CHAR8 **FixupData, > + IN UINT64 Adjust > + ) > +{ > + UINT8 RelocType; > + UINT64 Value =3D 0; > + UINT64 Tmp1 =3D 0; > + UINT64 Tmp2 =3D 0; > + > + RelocType =3D (*Reloc) >> 12; > + > + switch (RelocType) { > + case EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA: > + Value =3D (*(UINT32*)Fixup & 0x1ffffe0) << 7 | /* lu12i.w 20= bits from > bit5 */ > + (*((UINT32*)Fixup + 1) & 0x3ffc00) >> 10; /* ori 12bits = from bit10 */ > + Tmp1 =3D *((UINT32*)Fixup + 2) & 0x1ffffe0; /* lu32i.d 20= bits from bit5 > */ > + Tmp2 =3D *((UINT32*)Fixup + 3) & 0x3ffc00; /* lu52i.d 12= bits from > bit10 */ > + Value =3D Value | (Tmp1 << 27) | (Tmp2 << 42); > + Value +=3D Adjust; Please use double back slash for the comments in the function in this file. Abner > + > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x1ffffe0) | (((Value >> 1= 2) & > 0xfffff) << 5); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UI= NT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x3ffc00) | ((Value & 0xff= f) << > 10); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UI= NT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x1ffffe0) | (((Value >> 3= 2) & > 0xfffff) << 5); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UI= NT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + > + Fixup +=3D sizeof(UINT32); > + *(UINT32*)Fixup =3D (*(UINT32*)Fixup & ~0x3ffc00) | (((Value >> 52= ) & > 0xfff) << 10); > + if (*FixupData !=3D NULL) { > + *FixupData =3D ALIGN_POINTER (*FixupData, sizeof (UI= NT32)); > + *(UINT32 *) (*FixupData) =3D *(UINT32*)Fixup; > + *FixupData =3D *FixupData + sizeof (UINT32); > + } > + break; > + default: > + return RETURN_UNSUPPORTED; > + } > + > + return RETURN_SUCCESS; > +} > + > +/** > + Returns TRUE if the machine type of PE/COFF image is supported. > Supported > + does not mean the image can be executed it means the PE/COFF loader > supports > + loading and relocating of the image type. It's up to the caller to sup= port > + the entry point. > + > + @param Machine Machine type from the PE Header. > + > + @return TRUE if this PE/COFF loader can load the image > + > +**/ > +BOOLEAN > +PeCoffLoaderImageFormatSupported ( > + IN UINT16 Machine > + ) > +{ > + if (Machine =3D=3D IMAGE_FILE_MACHINE_LOONGARCH64) { > + return TRUE; > + } > + > + return FALSE; > +} > + > +/** > + Performs an LOONGARCH-based specific re-relocation fixup and is a no-o= p > on other > + instruction sets. This is used to re-relocated the image into the EFI = virtual > + space for runtime calls. > + > + @param Reloc The pointer to the relocation record. > + @param Fixup The pointer to the address to fix up. > + @param FixupData The pointer to a buffer to log the fixups. > + @param Adjust The offset to adjust the fixup. > + > + @return Status code. > + > +**/ > +RETURN_STATUS > +PeHotRelocateImageEx ( > + IN UINT16 *Reloc, > + IN OUT CHAR8 *Fixup, > + IN OUT CHAR8 **FixupData, > + IN UINT64 Adjust > + ) > +{ > + /* to check */ > + return PeCoffLoaderRelocateImageEx (Reloc, Fixup, FixupData, Adjust); > +} > -- > 2.27.0 >=20 >=20 >=20 >=20 >=20