public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Shi, Steven" <steven.shi@intel.com>
To: Zenith432 <zenith432@users.sourceforge.net>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH v2] BaseTools/GenFw: Add X64 GOTPCREL Support to GenFw
Date: Mon, 2 Jul 2018 09:22:12 +0000	[thread overview]
Message-ID: <06C8AB66E78EE34A949939824ABE2B313B791561@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1917777633.1686290.1528375781778@mail.yahoo.com>

Hi Zenith,
I like your patch. Sorry for the late response. I see your patch  has no impact to current supported relocation types, and I also hope we can add more relocation types in our GenFw tool. 
Below are some code style issues in your patch:

 
> +STATIC
> +VOID
> +FindElfGOTSectionFromGOTEntryElfRva (
> +  Elf64_Addr GOTEntryElfRva
> +  )
> +{
> +  UINT32 i;
> +  if (mGOTShdr != NULL) {
> +    if (GOTEntryElfRva >= mGOTShdr->sh_addr &&
> +        GOTEntryElfRva <  mGOTShdr->sh_addr + mGOTShdr->sh_size)
> +      return;

We usually use the {} to brace the  if branch statements, even it has only one statement,  like this:
    if (GOTEntryElfRva >= mGOTShdr->sh_addr &&
        GOTEntryElfRva <  mGOTShdr->sh_addr + mGOTShdr->sh_size){
        return;
    }


> +STATIC
> +BOOLEAN
> +AccumulateCoffGOTEntries (
> +  UINT32 GOTCoffEntry
> +  )
> +{
> +  UINT32 i;
> +  if (mGOTCoffEntries != NULL) {
> +    for (i = 0; i < mGOTNumCoffEntries; i++)
> +      if (mGOTCoffEntries[i] == GOTCoffEntry)
> +        return FALSE;
Same issue as above, we usually always use {} to include if true branch statement like this:
      if (mGOTCoffEntries[i] == GOTCoffEntry){
        return FALSE;
      }

> +STATIC
> +int
> +__comparator (
> +  const void* lhs,
> +  const void* rhs
> +  )
> +{
> +  if (*(const UINT32*)lhs < *(const UINT32*)rhs)
> +    return -1;
> +  return *(const UINT32*)lhs > *(const UINT32*)rhs;
> +}
We usually don't use '__' as prefix for a function, could you enhance the comparator() name and add {} to include if branch statement?


> +STATIC
> +VOID
> +EmitGOTRelocations (
> +  VOID
> +  )
> +{
> +  UINT32 i;
> +  if (mGOTCoffEntries == NULL)
> +    return;
Please add {} to include if branch statement


> +        if (mEhdr->e_machine == EM_X86_64 && RelShdr->sh_info ==
> mGOTShindex) {
> +          //
> +          // Tack relocations for GOT entries after other relocations for
> +          //   the section the GOT is in, as it's usually found at the end
> +          //   of the section.
> +          //
> +          EmitGOTRelocations();
> +        }
>        }
>      }
>    }
> 
> +  if (mEhdr->e_machine == EM_X86_64) {
> +    //
> +    // Just in case GOT is in a section with no other relocations
> +    //
> +    EmitGOTRelocations();
> +  }
Could we combine the two EmitGOTRelocations() invokes and only keep the second one?

Thanks
Steven


  parent reply	other threads:[~2018-07-02  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1917777633.1686290.1528375781778.ref@mail.yahoo.com>
2018-06-07 12:49 ` [PATCH v2] BaseTools/GenFw: Add X64 GOTPCREL Support to GenFw Zenith432
2018-06-08  4:02   ` Andrew Fish
2018-07-02  9:22   ` Shi, Steven [this message]
     [not found] <1761571963.2244772.1528455976855.ref@mail.yahoo.com>
2018-06-08 11:06 ` Zenith432

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=06C8AB66E78EE34A949939824ABE2B313B791561@shsmsx102.ccr.corp.intel.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