[PATCH] D144872: [AIX] Align the content of an xcoff object file which has auxiliary header in big archive.

Digger Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 13:57:27 PDT 2023


DiggerLin added inline comments.


================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:314
+  uint64_t PreHeadPadSize = 0;
+  std::unique_ptr<SymbolicFile> SymFile = nullptr;
 };
----------------
jhenderson wrote:
> No need for explicit assignment of `nullptr` - `unique_ptr`'s default constructor leaves it in an empty state.
it need it , otherwise there is compiler error on 
line 327
 "return {{}, std::move(Header), Names, Pad ? "\n" : ""};" 

as "missing field 'SymFile' initializer [-Werror,-Wmissing-field-initializers]"


================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:597
   // header.
-  unsigned PrevOffset = 0;
-  for (const NewArchiveMember &M : NewMembers) {
----------------
jhenderson wrote:
> Why has this variable been renamed?
I think "Pre" is more concise for the abbreviation of previous than "Prev" , I search from internet , the "Prev" is better , I change back.


================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:618
+
+  for (auto M = NewMembers.begin(); M < NewMembers.end(); M++) {
     std::string Header;
----------------
jhenderson wrote:
> I'm not sure I understand the changes to this loop. Why do you need to know anything about the next member to know how much padding the current member requires?
there is field  "char ar_nxtmem[20]"   /* Next member offset-decimal */" 
in the "File Member Header" in big archive
, we need to calculate the padding before the header if there is.


================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:683
+                                       alignTo((M + 1)->MemberName.size(), 2);
+        uint64_t NextMemHeadPadSize =
+            alignToPowerOf2(OffsetToNextMemData,
----------------
stephenpeckham wrote:
> It's possible to have a loadable object with a very large text or data alignment. A sanity check would be useful here.  The AIX ar command caps the alignment at 2^12 (the typical PAGESIZE on an AIX system).
the pos points to the begin of the header of member file, it not be aligned, only the data of the  member file is aligned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144872



More information about the llvm-commits mailing list