summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/ArchiveWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Reapply r250906 with many suggested updates from Rafael Espindola.Kevin Enderby2015-11-051-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The needed lld matching changes to be submitted immediately next, but this revision will cause lld failures with this alone which is expected. This removes the eating of the error in Archive::Child::getSize() when the characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. These changes will require corresponding changes to the lld project. That will be committed immediately after this change. But this revision will cause lld failures with this alone which is expected. llvm-svn: 252192
* Avoid implicitly constructing a Archive::child_iterator.Rafael Espindola2015-11-021-10/+10
| | | | llvm-svn: 251794
* Use Child instead of child_iterator in the archive writer.Rafael Espindola2015-11-011-5/+5
| | | | | | | We never need to pass end(). This will also remove some complication once we start adding error checking. llvm-svn: 251758
* Backing out commit r250906 as it broke lld.Kevin Enderby2015-10-211-10/+7
| | | | llvm-svn: 250908
* This removes the eating of the error in Archive::Child::getSize() when the ↵Kevin Enderby2015-10-211-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | characters in the size field in the archive header for the member is not a number. To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib. Then the tools and can handle the error in whatever way is appropriate for that tool. So the solution is to plumb all the ErrorOr stuff through everything that touches archives. This include its iterators as one can create an Archive object but the first or any other Child object may fail to be created due to a bad size field in its header. Thanks to Lang Hames on the changes making child_iterator contain an ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add operator overloading for * and -> . We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash” and using report_fatal_error() to move the error checking will cause the program to stop, neither of which are really correct in library code. There are still some uses of these that should be cleaned up in this library code for other than the size field. Also corrected the code where the size gets us to the “at the end of the archive” which is OK but past the end of the archive will return object_error::parse_failed now. The test cases use archives with text files so one can see the non-digit character, in this case a ‘%’, in the size field. llvm-svn: 250906
* Untabify.NAKAMURA Takumi2015-09-221-1/+1
| | | | llvm-svn: 248264
* Fix handling of relative paths in thin archives.Rafael Espindola2015-07-161-3/+32
| | | | | | The member has to end up with a path relative to the archive. llvm-svn: 242362
* llvm-ar: Don't write the directory in the string table.Rafael Espindola2015-07-151-1/+1
| | | | | | | We were already doing the right thing for short file names, but not long ones. llvm-svn: 242354
* Silence GCC -Wparenthesis warningDavid Majnemer2015-07-151-3/+2
| | | | llvm-svn: 242348
* For new archive member we only need to store the full path.Rafael Espindola2015-07-151-4/+4
| | | | | | | We were storing both the path and the file name, which was redundant and easy to get confused up with. llvm-svn: 242347
* Handle the error of trying to convert a regular archive to a thin one.Rafael Espindola2015-07-151-0/+3
| | | | | | While at it, test that we can add to a thin archive. llvm-svn: 242330
* Initial support for writing thin archives.Rafael Espindola2015-07-151-13/+24
| | | | llvm-svn: 242269
* Use a range loop.Rafael Espindola2015-07-141-4/+2
| | | | llvm-svn: 242250
* Add support deterministic output in llvm-ar and make it the default.Rafael Espindola2015-07-131-17/+43
| | | | llvm-svn: 242061
* llvm-ar: Pad the symbol table to 4 bytes.Rafael Espindola2015-07-091-2/+5
| | | | | | | It looks like ld64 requires it. With this we seem to be able to bootstrap using llvm-ar+/usr/bin/true instead of ar+ranlib (currently on stage2). llvm-svn: 241842
* Basic support for BSD symbol tables in archives.Rafael Espindola2015-07-091-17/+39
| | | | | | | This could be optimized and for now we only produce __.SYMDEF and not "__.SYMDEF SORTED". llvm-svn: 241814
* Remove redundant variable. NFC.Rafael Espindola2015-07-091-2/+1
| | | | llvm-svn: 241810
* Add a helper to printing BE of LE depending on the format.Rafael Espindola2015-07-091-6/+10
| | | | | | | The gnu ar format uses BE numbers. The BSD one uses LE. Add a helper for one or the other. NFC for now, just removes some noise from the following patch. llvm-svn: 241808
* Extract printBSDMemberHeader.Rafael Espindola2015-07-091-22/+25
| | | | | | | It will get another use in the following patch. Also rename the other helper to printGNUSmallMemberHeader for consistency. llvm-svn: 241805
* Disallow Archive::child_iterator that don't point to an archive.Rafael Espindola2015-07-081-2/+0
| | | | | | NFC, just less error prone. llvm-svn: 241747
* Use a raw_svector_ostream and simplify a loop. NFC.Rafael Espindola2015-07-081-6/+3
| | | | llvm-svn: 241727
* Start adding support for writing archives in BSD format.Rafael Espindola2015-07-081-10/+30
| | | | | | | | No support for the symbol table yet (but will hopefully add it today). We always use the long filename format so that we can align the member, which is an advantage of the BSD format. llvm-svn: 241721
* Inline function into only use.Rafael Espindola2015-07-081-12/+6
| | | | llvm-svn: 241692
* Add a helper function to reduce a bit of code duplication.Rafael Espindola2015-07-081-25/+22
| | | | llvm-svn: 241691
* Use a range loop. NFC.Rafael Espindola2015-07-081-8/+6
| | | | llvm-svn: 241685
* [ArchiveWriter] Use EndianStream. No functional change intended.Benjamin Kramer2015-06-171-9/+4
| | | | llvm-svn: 239913
* Don't use std::errc.Rafael Espindola2015-06-131-1/+2
| | | | | | | | | | | | | | | | | | | | | As noted on Errc.h: // * std::errc is just marked with is_error_condition_enum. This means that // common patters like AnErrorCode == errc::no_such_file_or_directory take // 4 virtual calls instead of two comparisons. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. llvm-svn: 239683
* Fix Windows build.Peter Collingbourne2015-06-081-0/+4
| | | | llvm-svn: 239279
* llvm-ar: Move archive writer to Object.Peter Collingbourne2015-06-081-0/+338
No functional change intended, other than some minor changes to certain diagnostics. Differential Revision: http://reviews.llvm.org/D10296 llvm-svn: 239278
OpenPOWER on IntegriCloud