[PATCH] D38193: Pre compute the tail of the archive

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 11:02:52 PDT 2017


Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu added inline comments.
>
>
> ================
> Comment at: lib/Object/ArchiveWriter.cpp:311-318
>    // ld64 expects the members to be 8-byte aligned for 64-bit content and at
>    // least 4-byte aligned for 32-bit content.  Opt for the larger encoding
>    // uniformly.
>    // We do this for all bsd formats because it simplifies aligning members.
>    unsigned Alignment = isBSDLike(Kind) ? 8 : 2;
> -  unsigned Pad = OffsetToAlignment(Out.tell(), Alignment);
> -  while (Pad--)
> -    Out.write(uint8_t(0));
> +  unsigned Pad = OffsetToAlignment(Size, Alignment);
> +  Size += Pad;
> ----------------
> This is not new code, but I wonder if we can just align all members to 8 bytes. Is there any reason not to do that?

In general only the bsd formats support aligning an arbitrary member. In
the particular case of the symbol table, yes, we can align the member
the follows it.

It is a format change, so it would probably be best to do it in a
followup patch as this one should be a nop.

Cheers,
Rafael


More information about the llvm-commits mailing list