Skip to content

Commit

Permalink
Fix file paths in .repro tar file
Browse files Browse the repository at this point in the history
Previously, all pathnames were accidentally recorded as the name of
the tar file itself.

Fixes #1227
  • Loading branch information
rui314 committed Mar 25, 2024
1 parent ee6907f commit 32c4a09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ void write_repro_file(Context<E> &ctx) {
// We reopen a file because we may have modified the contents of mf
// in memory, which is mapped with PROT_WRITE and MAP_PRIVATE.
MappedFile *mf2 = must_open_file(ctx, mf->name);
tar->append(path, mf2->get_contents());
tar->append(to_abs_path(mf->name), mf2->get_contents());
mf2->unmap();
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/elf/repro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ $CC -B. -o $t/exe $t/a.o
$CC -B. -o $t/exe $t/a.o -Wl,-repro

tar -C $t -xf $t/exe.repro.tar
tar -C $t -tvf $t/exe.repro.tar | grep -q ' exe.repro/.*/a.o'
grep -q /a.o $t/exe.repro/response.txt
grep -q '[ms]old' $t/exe.repro/version.txt

rm -rf $t/exe.repro $t/exe.repro.tar

MOLD_REPRO=1 $CC -B. -o $t/exe $t/a.o
tar -C $t -tvf $t/exe.repro.tar | grep -q ' exe.repro/.*/a.o'
tar -C $t -xf $t/exe.repro.tar
grep -q /a.o $t/exe.repro/response.txt
grep -q '[ms]old' $t/exe.repro/version.txt

0 comments on commit 32c4a09

Please sign in to comment.