[PATCH] D100375: [yaml2obj] Enable support for parsing 64-bit XCOFF.

EsmeYi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 15 20:33:50 PDT 2021


Esme added inline comments.


================
Comment at: llvm/lib/ObjectYAML/XCOFFEmitter.cpp:145
   // The default format of the object file is XCOFF32.
   InitFileHdr.Magic = XCOFF::XCOFF32;
   InitFileHdr.NumberOfSections = Obj.Sections.size();
----------------
Esme wrote:
> sfertile wrote:
> > Shouldn't this be updated to assign `XCOFF64` magic number when `Is64Bit` is true? It seems odd not to, although looking at the other parts of the code I think it will still work. I missed the previous review, so can you help me understand why we need an `InitFileHdr` and the file header that's a member of Obj? The mixture of duplication, and sometimes having the relevant/correct info on Obj.Header and sometimes on InitFileHdr is rather cumbersome to follow.
> Most of the key-values are optional in YAML, which allows users to write test inputs with more flexibility. For some optional fields, we have to calculated the default values that are derived from the contents of the YAML, like `InitFileHdr.NumberOfSymTableEntries`.  And we have an option to override that value when writing to object file, that is, use the derived value when the field is omitted, otherwise keep the value that defined in YAML.
> 
> The MagicNumber in FileHeader is optional, and we use `XCOFF::XCOFF32` as a default value if user did not define the key-value in YAML.
In addition, for some values such as offset, they must be finalized in advance to write a correct object file, regardless of whether the value is omitted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100375/new/

https://reviews.llvm.org/D100375



More information about the llvm-commits mailing list