[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
Wed Aug 16 06:42:05 PDT 2023
DiggerLin marked 2 inline comments as done.
DiggerLin added inline comments.
================
Comment at: llvm/lib/Object/ArchiveWriter.cpp:1173
for (const MemberData &M : Data) {
+ for (uint64_t i = 0; i < M.PreHeadPadSize; i++)
+ Out << '\0';
----------------
jhenderson wrote:
> DiggerLin wrote:
> > jhenderson wrote:
> > > It may be slightly more efficient to do something like:
> > > ```
> > > OS << std::string(M.PreHeadPadSize, '\0');
> > > ```
> > > It's certainly a little more elegant. Alternatively, you could use `std::fill_n`. There are good explanations of both these at https://stackoverflow.com/a/11421689.
> > we write M.PreHeadPadSize of '\0' , using std::string(M.PreHeadPadSize, '\0') , the string is a empty string , the `OS << std::string(M.PreHeadPadSize, '\0') ` do not output M.PreHeadPadSize of '\0'
> Did you actually try my suggestion? Your statement is wrong. I've tried it with some simple code and it works fine - `OS << std::string(10, '\0')` writes 10 null bytes to the output.
>
> `std::string(M.PreHeadPadSize, '\0')` constructs a `std::string` that contains `M.PreHeadPadSize` null bytes. It is NOT an empty string (although using `.c_str()` will make it look like it is).
it work, thanks
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