aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ArchiveWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-06-04[llvm-ar] Reapply Fix relative thin archive path handlingOwen Reynolds1-17/+34
Includes a fix for an introduced build failure due to a post c++11 use of std::mismatch. This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362484
2019-06-03Revert "[llvm-ar] Fix relative thin archive path handling"Dmitri Gribenko1-34/+17
This reverts commit r362407. It broke compilation of llvm/lib/Object/ArchiveWriter.cpp: error: type 'llvm::sys::path::const_iterator' does not provide a call operator llvm-svn: 362413
2019-06-03[llvm-ar] Fix relative thin archive path handlingOwen Reynolds1-17/+34
This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command. Differential Revision: https://reviews.llvm.org/D59491 llvm-svn: 362407
2019-05-10[Object] Change SymbolicFile::printSymbolName to use ErrorFangrui Song1-2/+2
llvm-svn: 360414
2019-02-19[libObject][NFC] Use sys::path::convert_to_slash.Jordan Rupprecht1-5/+1
Summary: As suggested in rL353995 Reviewers: compnerd Reviewed By: compnerd Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58298 llvm-svn: 354364
2019-02-13[llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht1-64/+48
Summary: When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, when flattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). Reviewers: mstorsjo, pcc, ruiu, davide, david2050, inglorion Reviewed By: ruiu Subscribers: void, jdoerfert, tpimh, mgorny, hans, nickdesaulniers, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57842 llvm-svn: 353995
2019-02-08Revert r353424 "[llvm-ar][libObject] Fix relative paths when nesting thin ↵Hans Wennborg1-12/+59
archives." This broke the Chromium build on Windows, see https://crbug.com/930058 > Summary: > When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, whe > lattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). > > As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. > > This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). > > Reviewers: mstorsjo, pcc, ruiu, davide, david2050 > > Subscribers: hiraditya, llvm-commits > > Tags: #llvm > > Differential Revision: https://reviews.llvm.org/D57842 This reverts commit bf990ab5aab03aa0aac53c9ef47ef264307804ed. llvm-svn: 353507
2019-02-07[llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht1-59/+12
Summary: When adding one thin archive to another, we currently chop off the relative path to the flattened members. For instance, when adding `foo/child.a` (which contains `x.txt`) to `parent.a`, when flattening it we should add it as `foo/x.txt` (which exists) instead of `x.txt` (which does not exist). As a note, this also undoes the `IsNew` parameter of handling relative paths in r288280. The unit test there still passes. This was reported as part of testing the kernel build with llvm-ar: https://patchwork.kernel.org/patch/10767545/ (see the second point). Reviewers: mstorsjo, pcc, ruiu, davide, david2050 Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57842 llvm-svn: 353424
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-19[llvm-ar] Simplify string table get-or-insert pattern with .insert, NFCReid Kleckner1-6/+4
llvm-svn: 349681
2018-12-19[Object] Deduplicate long archive member namesPeter Wu1-4/+22
Summary: Import libraries as created by llvm-dlltool always use the same archive member name for every object file (namely, the DLL library name). Ensure that long names are not repeatedly stored in the string table. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D55860 llvm-svn: 349637
2018-10-10llvm-ar: Darwin archive format fixes.James Y Knight1-26/+35
* Support writing the DARWIN64 symbol table format. * In darwin archives, emit a symbol table whenever requested, even when there are no members, as the apple linker will abort if given an archive without a symbol table. Added tests for same, and also simplified and moved the GNU 64-bit symbol table test into archive-symtab.test. llvm-svn: 344183
2018-10-04Give same-named members unique timestamps on Darwin in llvm-ar.James Y Knight1-7/+70
This change ensures that the (membername,timestamp) tuple uniquely identifies an entry in an archive for format=darwin, in deterministic mode (which is the default). That, then, enables lldb and dsymutil to locate the appropriate object within the archive. Differential Revision: https://reviews.llvm.org/D47659 llvm-svn: 343805
2018-09-11[object] Improve the performance of getSymbols used by ArchiveWriterAlexander Shaposhnikov1-11/+23
In this diff we adjust the code of getSymbols to avoid creating LLVMContext when it's not necessary. Without this patch when the function getSymbols was called on a MachO object with a __bitcode section it was parsing the embedded bitcode and then ignoring the result. Test plan: make check-all Differential revision: https://reviews.llvm.org/D51759 llvm-svn: 341998
2018-07-20[COFF] Adjust how we flag weak externalsMartin Storsjo1-2/+1
This fixes PR36096. Originally based on a patch by Martell Malone. Differential Revision: https://reviews.llvm.org/D44357 llvm-svn: 337613
2018-05-18Support: Simplify endian stream interface. NFCI.Peter Collingbourne1-4/+2
Provide some free functions to reduce verbosity of endian-writing a single value, and replace the endianness template parameter with a field. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47032 llvm-svn: 332757
2018-04-29s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber1-1/+1
LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. llvm-svn: 331127
2018-03-28[llvm-ar] Support multiple dashed optionsPeter Collingbourne1-9/+13
This allows syntax like: $ llvm-ar -c -r -u file.a file.o This is in addition to the other formats that are already supported: $ llvm-ar cru file.a file.o $ llvm-ar -cru file.a file.o Patch by Tom Anderson! Differential Revision: https://reviews.llvm.org/D44452 llvm-svn: 328716
2017-12-01Add flag to ArchiveWriter to test GNU64 format more efficientlyJake Ehrlich1-1/+10
Even with the sparse file optimizations the SYM64 test can still be painfully slow. This unnecessarily slows down devs. It's critical that we test that the switch to the SYM64 format occurs at 4GB but there isn't any better of a way to fake the size of the file than sparse files. This change introduces a flag that allows the cutoff to be arbitrarily set to whatever power of two is desired. The flag is hidden as it really isn't meant to be used outside this one test. This is unfortunate but appears necessary, at least until the average hard drive is much faster. The changes to the test require some explanation. Prior to this change we knew that the SYM64 format was being used because the file was simply too large to have validly handled this case if the SYM64 format were not used. To ensure that the SYM64 format is still being used I am grepping the file for "SYM64". Without changing the filename however this would be pointless because "SYM64" would occur in the file either way. So the filename of the test is also changed in order to avoid this issue. Differential Revision: https://reviews.llvm.org/D40632 llvm-svn: 319507
2017-11-14Use TempFile in llvm-ar. NFC.Rafael Espindola1-11/+7
llvm-svn: 318127
2017-11-03Reland "Add support for writing 64-bit symbol tables for archives when ↵Jake Ehrlich1-9/+55
offsets become too large for 32-bit" Tests were failing because some bots were running out of address space and memory. Additionally the test was very slow. These issues were solved by changing the test to take advantage of sparse filse and restricting the test to run only on 64-bit systems. This should fix https://bugs.llvm.org//show_bug.cgi?id=34189 This change makes it so that if writing a K_GNU style archive, you need to output a > 32-bit offset it should output in K_GNU64 style instead. Differential Revision: https://reviews.llvm.org/D36812 llvm-svn: 317352
2017-10-27Revert "Add support for writing 64-bit symbol tables for archives when ↵Jake Ehrlich1-55/+9
offsets become too large for 32-bit" This reverts commit r316805. llvm-svn: 316813
2017-10-27Add support for writing 64-bit symbol tables for archives when offsets ↵Jake Ehrlich1-9/+55
become too large for 32-bit This should fix https://bugs.llvm.org//show_bug.cgi?id=34189 This change makes it so that if writing a K_GNU style archive, you need to output a > 32-bit offset it should output in K_GNU64 style instead. Differential Revision: https://reviews.llvm.org/D36812 llvm-svn: 316805
2017-10-03Pre-compute the tail of the archiveRafael Espindola1-177/+184
An archive looks like <header> <symbol table> <tail> The symbol table refers to offsets in the tail. A complication is that we would like to support symbol tables that use 64 bit offsets if it turns out that any of the offsets is too big. This patch changes the archive writer to first compute the tail. We cannot just compute one big StringRef since that would require reading every member upfront, but we can represent it as a series of StringRefs. Having done that it is much easier to compute the symbol table and all offsets are computed before it is written. With this if there is an accounting problem it will show up with a regular symbol table, not just when a 64 bit one is needed. llvm-svn: 314844
2017-09-23[Support] Rename tool_output_file to ToolOutputFile, NFCReid Kleckner1-1/+1
This class isn't similar to anything from the STL, so it shouldn't use the STL naming conventions. llvm-svn: 314050
2017-09-22Move code to a helper function. NFC.Rafael Espindola1-7/+13
Part of a patch by Jake Ehrlich! llvm-svn: 314012
2017-09-22llvm-ar: align the first archive member consistently.Rafael Espindola1-3/+5
Before we were aligning the member after the symbol table to 4 but other members to 8. llvm-svn: 314010
2017-09-22llvm-ar: Don't add an unnecessary alignment in gnu mode.Rafael Espindola1-1/+2
This is mostly for getting stricter testing in preparation for future changes. llvm-svn: 314000
2017-09-21Convert the archive writer to use Error.Rafael Espindola1-13/+13
This found one place in lld that was not checking the error. llvm-svn: 313937
2017-09-21Use raw_ostream in functions that don't need to seek. NFC.Rafael Espindola1-5/+5
llvm-svn: 313935
2017-09-21Simplify the logic for truncating UID and GID. NFC.Rafael Espindola1-12/+9
llvm-svn: 313933
2017-09-21Use ArrayRef. NFC.Rafael Espindola1-1/+1
llvm-svn: 313895
2017-09-20Rename K_MIPS64 to K_GNU64Jake Ehrlich1-1/+1
This patch renames K_MIPS64 to K_GNU64 as part of a change to add support for writing archives with 64-bit indexes in the symbol table. llvm-svn: 313787
2017-08-30Simplify writeArchive return type.Rui Ueyama1-6/+5
writeArchive returned a pair, but the first element of the pair is always its first argument on failure, so it doesn't make sense to return it from the function. This patch change the return type so that it does't return it. Differential Revision: https://reviews.llvm.org/D37313 llvm-svn: 312177
2017-07-18llvm: add llvm-dlltool support to the archiverMartell Malone1-1/+2
A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29892 This reapplies rL308329, which was reverted in rL308374 llvm-svn: 308379
2017-07-18Revert r308329: llvm: add llvm-dlltool support to the archiverRui Ueyama1-2/+1
This reverts commit r308329 because it broke buildbots. llvm-svn: 308374
2017-07-18llvm: add llvm-dlltool support to the archiverMartell Malone1-1/+2
A PE COFF spec compliant import library generator. Intended to be used with mingw-w64. Supports: PE COFF spec (section 8, Import Library Format) PE COFF spec (Aux Format 3: Weak Externals) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29892 llvm-svn: 308329
2017-06-12[llvm-ar] Make llvm-lib behave more like the MSVC archiverReid Kleckner1-6/+8
Summary: Use the filepath used to open the archive member as the archive member name instead of the file basename. This path might be absolute or relative. This is important because the archive member name will show up in the PDB, and we want our PDBs to look as much like MSVC's as possible. This also helps avoid an issue in our PDB module descriptor writing code, which assumes that all module names are unique. Relative paths still aren't guaranteed to be unique, but they're much better than basenames, which definitely aren't unique. Reviewers: ruiu, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33575 llvm-svn: 305223
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner1-1/+2
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
2017-03-16ArchiveWriter: Remove unused variables. NFC.Peter Collingbourne1-4/+0
llvm-svn: 297987
2017-03-14Archives require a symbol table on Solaris, even if empty.Rafael Espindola1-0/+5
On Solaris ld (and some other tools that use the underlying utility libraries, such as elfdump) chokes on an archive library that has no symbol table. The Solaris tools always create one, even if it's empty. That bug has been fixed in the latest development line, and can probably be backported to a supported release, but it would be nice if LLVM's archiver could emit the empty symbol table, too. Patch by Danek Duvall! llvm-svn: 297773
2017-02-22Move llvm_unreachable out of switch.Rafael Espindola1-2/+5
This should make gcc happy and still produce a clang warning if we add another value to the enum. llvm-svn: 295865
2017-02-22Fix -Wcovered-switch-default.Rui Ueyama1-3/+1
llvm-svn: 295799
2017-02-21Don't modify archive members unless really needed.Rafael Espindola1-18/+31
For whatever reason ld64 requires that member headers (not the member themselves) should be aligned. The only way to do that is to edit the previous member so that it ends at an aligned boundary. Since modifying data put in an archive is an undesirable property, llvm-ar should only do it when it is absolutely necessary. llvm-svn: 295765
2017-02-09Object: pad out BSD archive members to 8-bytesSaleem Abdulrasool1-1/+11
ld64 requires its archive members to be 8-byte aligned for 64-bit content and 4-byte aligned for 32-bit content. Opt for the larger alignment requirement. This ensures that ld64 can consume archives generated by llvm-ar. Thanks to Kevin Enderby for the hint about the ld64/cctools behaviours! Resolves PR28361! llvm-svn: 294615
2017-02-09Object: add a comment explaining a divergenceSaleem Abdulrasool1-0/+2
Add a note about the reason for the divergence from the specification for ld64. Addresses post-commit review comments from Davide. NFC. llvm-svn: 294594
2017-02-09Object: pad BSD ar string table to 4-bytesSaleem Abdulrasool1-0/+4
cctools would pad the string table to a sizeof(int32_t) (explicitly printed out by cctools rather than 4). This adjusts the string table to make it more compatible with cctools, but is insufficient to make ld64 happy. llvm-svn: 294557
2016-11-30Only computeRelativePath() on new membersDavid Callahan1-3/+8
Summary: When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive. Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified. Reviewers: rafael, davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27217 llvm-svn: 288280
2016-11-15Object: replace backslashes with slashes in embedded relative thin archive ↵Peter Collingbourne1-0/+6
paths on Windows. This makes these thin archives portable between *nix and Windows. Differential Revision: https://reviews.llvm.org/D26696 llvm-svn: 287038
2016-10-24[Object] Replace TimeValue with std::chronoPavel Labath1-21/+24
Summary: Most of the changes are very straight-forward. The only choice I had to make was to use second-precision time points in the Archive classes. I did this because the archive files use that precision in the on-disk representation anyway. Reviewers: rafael, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25773 llvm-svn: 284974