[llvm-dev] is LLVM's writeArchive broken for Darwin Archives?
Zhang via llvm-dev
llvm-dev at lists.llvm.org
Tue Aug 7 00:28:59 PDT 2018
Hi:
Currently I'm using the following code to build an archive in my program after generating the object files that I need:
```
//Filename is the object file emitted by TargetMachine from LLVM IR
vector<NewArchiveMember> arMembers;
Expected<NewArchiveMember> ExpNAM = NewArchiveMember::getFile(Filename, true);
if (!ExpNAM) {
handleAllErrors(ExpNAM.takeError(), [&](const ErrorInfoBase &EIB) {
errs() << "Error during reading compiled object : " << EIB.message()
<< "\n";
});
exit(-1);
}
arMembers.push_back(std::move(*ExpNAM));
```
Then another loop assembles some .S files and use the above code to read the emitted object file and push then into arMembers as well.
Finally I use ```writeArchive(ArchiveFilename, ArrayRef<NewArchiveMember>(arMembers), true,object::Archive::Kind::K_DARWIN64, true, false);``` to write the archive. No errors are reported up until this point.
Then I try to read the generated archive and verify it using the following code:
```
errs()<<"Verifying Archive\n";
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(ArchiveFilename);
if (!BinaryOrErr) {
handleAllErrors(BinaryOrErr.takeError(), [&](const ErrorInfoBase &EIB) {
errs() << "Error during reading archive : "
<< EIB.message() << "\n";
});
exit(-1);
}
```
This time I got an error message: Error during reading archive : truncated or malformed archive (terminator characters in archive member "iF" not the correct "`\n" values for the archive member header for XXXXXXXX)
Am I using these APIs wrong or they are simply broken. The exactly same code works perfectly fine when I emit assemblies for thumbv7 Android using K_GNU so I'm not sure about what to blame here. I'm currently using LLVM6 release
Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180807/04fdb822/attachment.html>
More information about the llvm-dev
mailing list