llvm-project
llvm-project copied to clipboard
Darwin format archives add white space to the end of extracted members
| Bugzilla Link | 42562 |
| Version | trunk |
| OS | All |
| CC | @sbc100 |
Extended Description
When outputting an archive in the darwin format, either explicitly with "--format" or by defualt on macOSX, white space is added to the end of extracted members. I believe this is due to the padding added to members due to alignment being included in the members size.
The result of this script is a different between the input and output file where the output contains a bunch of extra newlines.
Using --format=gnu makes the problem go away.
Looks like the problem code is in llvm/lib/Object/ArchiveWriter.cpp:computeMemberData where at adds the MemberPadding to Size.
I just ran into the same issue:
Script to reproduce the issue:
#!/bin/bash
set -x
set -e
AR="$PWD/../emsdk-master/upstream/bin/llvm-ar --format=darwin"
echo "hello.txt" > file.txt
rm -f libfoo.a
$AR crS libfoo.a file.txt
# Extra archive member and compare to original
cd tmp
$AR x ../libfoo.a
hexdump -C ../libfoo.a
diff -u file.txt ../file.txt