public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Leif Lindholm <leif@nuviainc.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>,
	"Feng, Bob C" <bob.c.feng@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image
Date: Sat, 5 Jun 2021 01:19:49 +0000	[thread overview]
Message-ID: <CO1PR11MB49305010C4A8B4000DF8FA748C3A9@CO1PR11MB4930.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CO1PR11MB4930C65D5B1A40B4956A7DDC8C3A9@CO1PR11MB4930.namprd11.prod.outlook.com>

Leif,
OVMF Bhyve GCC build succeeds without GenFW assertion issue.

I dumped the ELF image generated for OvmfPkg/Bhyve/AcpiTables/AcpiTables.
Below output shows that .text does have "AX" set:

---
$ readelf -S Hpet.dll
...
  [ 1] .text             PROGBITS         0000000000000000  00000140
       000000000000000c  0000000000000000  AX       0     0     64
---

It matches IsTextShdr() logic:
  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));

Can you please check the .text attributes in your ARM build?
(
I did try to build an ARM platform but failed with following errors:
gcc: error: unrecognized command line option '-mcmodel=small'

I downloaded "arm-none-eabi-gcc" in Ubuntu:
  lrwxrwxrwx 1 root root 25 Jun  5 09:18 /usr/bin/gcc -> /usr/bin/arm-non-eabi-gcc
)

> -----Original Message-----
> From: Ni, Ray
> Sent: Saturday, June 5, 2021 8:07 AM
> To: Leif Lindholm <leif@nuviainc.com>; devel@edk2.groups.io
> Cc: Liming Gao <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>
> Subject: RE: [edk2-devel] [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image
> 
> Leif,
> Sorry to hear that. It seems a CI gap that doesn't capture such errors.
> It looks like the logic update to detect .text section doesn't work in your case.
> 
> I am trying to build the OVMF Bhyve because I saw it contains an AcpiTables module that has .aslc file.
> 
> Thanks,
> Ray
> 
> 
> > -----Original Message-----
> > From: Leif Lindholm <leif@nuviainc.com>
> > Sent: Friday, June 4, 2021 9:31 PM
> > To: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>; Feng, Bob C <bob.c.feng@intel.com>
> > Subject: Re: [edk2-devel] [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image
> >
> > Hi Ray,
> >
> > On Wed, Jun 02, 2021 at 16:11:41 +0800, Ni, Ray wrote:
> > > From: Liming Gao <gaoliming@byosoft.com.cn>
> > >
> > > 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 <gaoliming@byosoft.com.cn>
> > > Reviewed-by: Feng Bob C <bob.c.feng@intel.com>
> >
> > This commit breaks many of the ARM platforms.
> >
> > I end up seeing
> >
> > GenFw: Elf64Convert.c:719: ScanSections64: Assertion `FALSE' failed.
> >
> > when generating certain ACPI tables.
> >
> > Note: this applies to both GCC5 and CLANG38 - it is not isolated to
> > CLANG8ELF.
> >
> > Reverting to commit c1aa3bab1259 makes these builds work again.
> >
> > /
> >     Leif
> >
> > > ---
> > >  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/GenFw/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
> > >    )
> > >  {
> > > -  return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC);
> > > +  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
> > >  }
> > >
> > >  STATIC
> > > @@ -261,7 +261,7 @@ IsDataShdr (
> > >    if (IsHiiRsrcShdr(Shdr)) {
> > >      return FALSE;
> > >    }
> > > -  return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
> > > +  return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
> > >  }
> > >
> > >  STATIC
> > > @@ -749,13 +749,7 @@ WriteSections32 (
> > >            if (SymName == NULL) {
> > >              SymName = (const UINT8 *)"<unknown>";
> > >            }
> > > -
> > > -          Error (NULL, 0, 3000, "Invalid",
> > > -                 "%s: Bad definition for symbol '%s'@%#x or unsupported symbol type.  "
> > > -                 "For example, absolute and undefined symbols are not supported.",
> > > -                 mInImageName, SymName, Sym->st_value);
> > > -
> > > -          exit(EXIT_FAILURE);
> > > +          continue;
> > >          }
> > >          SymShdr = GetShdrByIndex(Sym->st_shndx);
> > >
> > > diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/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
> > >    )
> > >  {
> > > -  return (BOOLEAN) ((Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == SHF_ALLOC);
> > > +  return (BOOLEAN) ((Shdr->sh_flags & (SHF_EXECINSTR | SHF_ALLOC)) == (SHF_EXECINSTR | SHF_ALLOC));
> > >  }
> > >
> > >  STATIC
> > > @@ -269,7 +269,7 @@ IsDataShdr (
> > >    if (IsHiiRsrcShdr(Shdr)) {
> > >      return FALSE;
> > >    }
> > > -  return (BOOLEAN) (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
> > > +  return (BOOLEAN) (Shdr->sh_flags & (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
> > >  }
> > >
> > >  STATIC
> > > @@ -1060,6 +1060,7 @@ WriteSections64 (
> > >
> > >              exit(EXIT_FAILURE);
> > >            }
> > > +          continue;
> > >          }
> > >          SymShdr = GetShdrByIndex(Sym->st_shndx);
> > >
> > > --
> > > 2.31.1.windows.1
> > >
> > >
> > >
> > > 
> > >
> > >

  reply	other threads:[~2021-06-05  1:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  8:11 [PATCH v2 0/6] Add CLANGDWARF toolchain for universal payload needs Ni, Ray
2021-06-02  8:11 ` [PATCH v2 1/6] BaseTools: Add ClangBase.lds for CLANG8 tool chain with max-page-size Ni, Ray
2021-06-02  8:11 ` [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image Ni, Ray
2021-06-04 13:31   ` [edk2-devel] " Leif Lindholm
2021-06-05  0:07     ` Ni, Ray
2021-06-05  1:19       ` Ni, Ray [this message]
2021-06-05  1:35       ` 回复: " gaoliming
2021-06-02  8:11 ` [PATCH v2 3/6] BaseTools: Update build_rule to skip CLANG resource section generation Ni, Ray
2021-06-02  8:11 ` [PATCH v2 4/6] BaseTools: Add new CLANG8ELF tool chain for new LLVM/CLANG8 Ni, Ray
2021-06-02  8:11 ` [PATCH v2 5/6] BaseTools: Update ClangBase.lds to keep dynamic section Ni, Ray
2021-06-02  8:11 ` [PATCH v2 6/6] BaseTools: Change CLANG8ELF to CLANGDWARF Ni, Ray
2021-06-04  5:42 ` 回复: [edk2-devel] [PATCH v2 0/6] Add CLANGDWARF toolchain for universal payload needs gaoliming
2021-06-04  8:57   ` Bob Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB49305010C4A8B4000DF8FA748C3A9@CO1PR11MB4930.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox