[lld] r268495 - Print the cpio trailer after every member.
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Tue May 10 12:08:25 PDT 2016
On Tue, May 10, 2016 at 8:48 AM, Rui Ueyama <ruiu at google.com> wrote:
> Looks like it should be 3 exclamation points.
>
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_11
>
Thanks for digging that up. I don't think we can get much more official
than POSIX. Can you add the link?
-- Sean Silva
>
>
> On Tue, May 10, 2016 at 12:31 AM, Sean Silva via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>>
>>
>> On Wed, May 4, 2016 at 5:47 AM, Rafael Espindola via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: rafael
>>> Date: Wed May 4 07:47:56 2016
>>> New Revision: 268495
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=268495&view=rev
>>> Log:
>>> Print the cpio trailer after every member.
>>>
>>> This is both simpler and safer. If we crash at any point, there is a
>>> valid cpio file to reproduce the crash.
>>>
>>> Thanks to Rui for the suggestion.
>>>
>>> Modified:
>>> lld/trunk/ELF/Driver.cpp
>>> lld/trunk/ELF/DriverUtils.cpp
>>> lld/trunk/ELF/Error.cpp
>>> lld/trunk/ELF/Error.h
>>>
>>> Modified: lld/trunk/ELF/Driver.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=268495&r1=268494&r2=268495&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/ELF/Driver.cpp (original)
>>> +++ lld/trunk/ELF/Driver.cpp Wed May 4 07:47:56 2016
>>> @@ -493,8 +493,6 @@ template <class ELFT> void LinkerDriver:
>>> for (auto *Arg : Args.filtered(OPT_wrap))
>>> Symtab.wrap(Arg->getValue());
>>>
>>> - maybeCloseReproArchive();
>>> -
>>> // Write the result to the file.
>>> if (Config->GcSections)
>>> markLive<ELFT>();
>>>
>>> Modified: lld/trunk/ELF/DriverUtils.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=268495&r1=268494&r2=268495&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/ELF/DriverUtils.cpp (original)
>>> +++ lld/trunk/ELF/DriverUtils.cpp Wed May 4 07:47:56 2016
>>> @@ -117,14 +117,8 @@ static std::string getDestPath(StringRef
>>> return Dest.str();
>>> }
>>>
>>> -static void maybePrintCpioMember(StringRef Path, StringRef Data) {
>>> - if (Config->Reproduce.empty())
>>> - return;
>>> -
>>> - if (!Driver->IncludedFiles.insert(Path).second)
>>> - return;
>>> -
>>> - raw_fd_ostream &OS = *Driver->ReproduceArchive;
>>> +static void maybePrintCpioMemberAux(raw_fd_ostream &OS, StringRef Path,
>>> + StringRef Data) {
>>> OS << "070707"; // c_magic
>>>
>>> // The c_dev/c_ino pair should be unique according to the spec, but
>>> no one
>>> @@ -144,19 +138,28 @@ static void maybePrintCpioMember(StringR
>>> OS << Data; // c_filedata
>>> }
>>>
>>> +static void maybePrintCpioMember(StringRef Path, StringRef Data) {
>>> + if (Config->Reproduce.empty())
>>> + return;
>>> +
>>> + if (!Driver->IncludedFiles.insert(Path).second)
>>> + return;
>>> + raw_fd_ostream &OS = *Driver->ReproduceArchive;
>>> + maybePrintCpioMemberAux(OS, Path, Data);
>>> +
>>> + // Print the trailer and seek back. This way we have a valid archive
>>> if we
>>> + // crash.
>>> + uint64_t Pos = OS.tell();
>>> + maybePrintCpioMemberAux(OS, "TRAILER!!!", "");
>>>
>>
>> Is it 2 or 3 exclamation points? The first source I find
>> https://www.mkssoftware.com/docs/man4/cpio.4.asp claims the trailer has
>> two exclamation points. Do you have a specific CPIO spec that you used and
>> could link?
>>
>> -- Sean Silva
>>
>>
>>> + OS.seek(Pos);
>>> +}
>>> +
>>> // Write file Src with content Data to the archive.
>>> void elf::maybeCopyInputFile(StringRef Src, StringRef Data) {
>>> std::string Dest = getDestPath(Src);
>>> maybePrintCpioMember(Dest, Data);
>>> }
>>>
>>> -void elf::maybeCloseReproArchive() {
>>> - if (!Driver->ReproduceArchive)
>>> - return;
>>> - maybePrintCpioMember("TRAILER!!!", "");
>>> - Driver->ReproduceArchive.reset();
>>> -}
>>> -
>>> // Quote a given string if it contains a space character.
>>> static std::string quote(StringRef S) {
>>> if (S.find(' ') == StringRef::npos)
>>>
>>> Modified: lld/trunk/ELF/Error.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=268495&r1=268494&r2=268495&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/ELF/Error.cpp (original)
>>> +++ lld/trunk/ELF/Error.cpp Wed May 4 07:47:56 2016
>>> @@ -29,7 +29,6 @@ void warning(const Twine &Msg) { llvm::e
>>> void error(const Twine &Msg) {
>>> *ErrorOS << Msg << "\n";
>>> HasError = true;
>>> - maybeCloseReproArchive();
>>> }
>>>
>>> void error(std::error_code EC, const Twine &Prefix) {
>>> @@ -39,7 +38,6 @@ void error(std::error_code EC, const Twi
>>>
>>> void fatal(const Twine &Msg) {
>>> llvm::errs() << Msg << "\n";
>>> - maybeCloseReproArchive();
>>> exit(1);
>>> }
>>>
>>>
>>> Modified: lld/trunk/ELF/Error.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=268495&r1=268494&r2=268495&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/ELF/Error.h (original)
>>> +++ lld/trunk/ELF/Error.h Wed May 4 07:47:56 2016
>>> @@ -18,8 +18,6 @@ namespace elf {
>>> extern bool HasError;
>>> extern llvm::raw_ostream *ErrorOS;
>>>
>>> -void maybeCloseReproArchive();
>>> -
>>> void log(const Twine &Msg);
>>> void warning(const Twine &Msg);
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160510/876147f7/attachment.html>
More information about the llvm-commits
mailing list