From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.10224.1622621531196528142 for ; Wed, 02 Jun 2021 01:12:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) IronPort-SDR: Rsx76C1KZcxhhOUYbyed78QQc/babsE7UFMCABsvMD6QapjaQ2Pg3l/KqZ4KpAe4vEa+nLxBOt //gxNc9jvMwQ== X-IronPort-AV: E=McAfee;i="6200,9189,10002"; a="267609206" X-IronPort-AV: E=Sophos;i="5.83,241,1616482800"; d="scan'208";a="267609206" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2021 01:12:10 -0700 IronPort-SDR: aUdIdz75m0WPz5d+X4XJM52zGM/DaAkRJzDeR1h2M/Us2V5UepevsiN34GDdU8YTyHjKLJBDxZ TK0AGYZRizNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,241,1616482800"; d="scan'208";a="479617445" Received: from ray-dev.ccr.corp.intel.com ([10.239.158.87]) by orsmga001.jf.intel.com with ESMTP; 02 Jun 2021 01:12:09 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Liming Gao , Feng Bob C Subject: [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image Date: Wed, 2 Jun 2021 16:11:41 +0800 Message-Id: <20210602081145.265-3-ray.ni@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20210602081145.265-1-ray.ni@intel.com> References: <20210602081145.265-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Liming Gao CLANG8ELF tool chain generated ELF image with the different attributes in section. Update GenFw to handle them. 1. .text section with writable attribute (support) 2. .reloc section has the symbol for *ABS* (skip) Signed-off-by: Liming Gao Reviewed-by: Feng Bob C --- BaseTools/Source/C/GenFw/Elf32Convert.c | 12 +++--------- BaseTools/Source/C/GenFw/Elf64Convert.c | 5 +++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/G= enFw/Elf32Convert.c index 2485b2cb7a..7c8a065678 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -238,7 +238,7 @@ IsTextShdr ( Elf_Shdr *Shdr=0D )=0D {=0D - return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) =3D=3D SHF_= ALLOC);=0D + return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) =3D=3D = (SHF_EXECINSTR | SHF_ALLOC));=0D }=0D =0D STATIC=0D @@ -261,7 +261,7 @@ IsDataShdr ( if (IsHiiRsrcShdr(Shdr)) {=0D return FALSE;=0D }=0D - return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) =3D=3D (SHF_= ALLOC | SHF_WRITE);=0D + return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLO= C)) =3D=3D (SHF_ALLOC | SHF_WRITE);=0D }=0D =0D STATIC=0D @@ -749,13 +749,7 @@ WriteSections32 ( if (SymName =3D=3D NULL) {=0D SymName =3D (const UINT8 *)"";=0D }=0D -=0D - Error (NULL, 0, 3000, "Invalid",=0D - "%s: Bad definition for symbol '%s'@%#x or unsupported sy= mbol type. "=0D - "For example, absolute and undefined symbols are not supp= orted.",=0D - mInImageName, SymName, Sym->st_value);=0D -=0D - exit(EXIT_FAILURE);=0D + continue;=0D }=0D SymShdr =3D GetShdrByIndex(Sym->st_shndx);=0D =0D diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/G= enFw/Elf64Convert.c index d097db8632..8fe672e984 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -246,7 +246,7 @@ IsTextShdr ( Elf_Shdr *Shdr=0D )=0D {=0D - return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) =3D=3D SHF_= ALLOC);=0D + return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) =3D=3D = (SHF_EXECINSTR | SHF_ALLOC));=0D }=0D =0D STATIC=0D @@ -269,7 +269,7 @@ IsDataShdr ( if (IsHiiRsrcShdr(Shdr)) {=0D return FALSE;=0D }=0D - return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) =3D=3D (SHF_= ALLOC | SHF_WRITE);=0D + return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLO= C)) =3D=3D (SHF_ALLOC | SHF_WRITE);=0D }=0D =0D STATIC=0D @@ -1060,6 +1060,7 @@ WriteSections64 ( =0D exit(EXIT_FAILURE);=0D }=0D + continue;=0D }=0D SymShdr =3D GetShdrByIndex(Sym->st_shndx);=0D =0D --=20 2.31.1.windows.1