llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Darwin format archives add white space to the end of extracted members

Open gbreynoo opened this issue 7 years ago • 2 comments

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.

gbreynoo avatar Jul 10 '19 13:07 gbreynoo

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.

sbc100 avatar Feb 04 '20 00:02 sbc100

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

sbc100 avatar Feb 04 '20 00:02 sbc100