summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/ArchiveWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Alignment][NFC] Remove unneeded llvm:: scoping on Align typesGuillaume Chatelet2019-09-271-5/+5
| | | | llvm-svn: 373081
* [Alignment] Move OffsetToAlignment to Alignment.hGuillaume Chatelet2019-09-121-6/+8
| | | | | | | | | | | | | | | | | Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet, JDevlieghere, alexshap, rupprecht, jhenderson Subscribers: sdardis, nemanjai, hiraditya, kbarton, jakehehrlich, jrtc27, MaskRay, atanasyan, jsji, seiya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D67499 llvm-svn: 371742
* [llvm-ar] Fix support for archives with members larger than 4GBOwen Reynolds2019-07-231-6/+15
| | | | | | | | | | | | | | | | llvm-ar outputs a strange error message when handling archives with members larger than 4GB due to not checking file size when passing the value as an unsigned 32 bit integer. This overflow issue caused malformed archives to be created.: https://bugs.llvm.org/show_bug.cgi?id=38058 This change allows for members above 4GB and will error in a case that is over the formats size limit, a 10 digit decimal integer. Differential Revision: https://reviews.llvm.org/D65093 llvm-svn: 366813
* [Support] Move llvm::MemoryBuffer to sys::fs::file_tReid Kleckner2019-07-101-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: On Windows, Posix integer file descriptors are a compatibility layer over native file handles provided by the C runtime. There is a hard limit on the maximum number of file descriptors that a process can open, and the limit is 8192. LLD typically doesn't run into this limit because it opens input files, maps them into memory, and then immediately closes the file descriptor. This prevents it from running out of FDs. For various reasons, I'd like to open handles to every input file and keep them open during linking. That requires migrating MemoryBuffer over to taking open native file handles instead of integer FDs. Reviewers: aganea, Bigcheese Reviewed By: aganea Subscribers: smeenai, silvas, mehdi_amini, hiraditya, steven_wu, dexonsmith, dang, llvm-commits, zturner Tags: #llvm Differential Revision: https://reviews.llvm.org/D63453 llvm-svn: 365588
* [llvm-ar] Reapply Fix relative thin archive path handlingOwen Reynolds2019-06-041-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
* Revert "[llvm-ar] Fix relative thin archive path handling"Dmitri Gribenko2019-06-031-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
* [llvm-ar] Fix relative thin archive path handlingOwen Reynolds2019-06-031-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
* [Object] Change SymbolicFile::printSymbolName to use ErrorFangrui Song2019-05-101-2/+2
| | | | llvm-svn: 360414
* [libObject][NFC] Use sys::path::convert_to_slash.Jordan Rupprecht2019-02-191-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
* [llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht2019-02-131-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
* Revert r353424 "[llvm-ar][libObject] Fix relative paths when nesting thin ↵Hans Wennborg2019-02-081-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
* [llvm-ar][libObject] Fix relative paths when nesting thin archives.Jordan Rupprecht2019-02-071-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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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
* [llvm-ar] Simplify string table get-or-insert pattern with .insert, NFCReid Kleckner2018-12-191-6/+4
| | | | llvm-svn: 349681
* [Object] Deduplicate long archive member namesPeter Wu2018-12-191-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
* llvm-ar: Darwin archive format fixes.James Y Knight2018-10-101-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
* Give same-named members unique timestamps on Darwin in llvm-ar.James Y Knight2018-10-041-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
* [object] Improve the performance of getSymbols used by ArchiveWriterAlexander Shaposhnikov2018-09-111-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
* [COFF] Adjust how we flag weak externalsMartin Storsjo2018-07-201-2/+1
| | | | | | | | | | This fixes PR36096. Originally based on a patch by Martell Malone. Differential Revision: https://reviews.llvm.org/D44357 llvm-svn: 337613
* Support: Simplify endian stream interface. NFCI.Peter Collingbourne2018-05-181-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
* s/LLVM_ON_WIN32/_WIN32/, llvmNico Weber2018-04-291-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
* [llvm-ar] Support multiple dashed optionsPeter Collingbourne2018-03-281-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
* Add flag to ArchiveWriter to test GNU64 format more efficientlyJake Ehrlich2017-12-011-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
* Use TempFile in llvm-ar. NFC.Rafael Espindola2017-11-141-11/+7
| | | | llvm-svn: 318127
* Reland "Add support for writing 64-bit symbol tables for archives when ↵Jake Ehrlich2017-11-031-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
* Revert "Add support for writing 64-bit symbol tables for archives when ↵Jake Ehrlich2017-10-271-55/+9
| | | | | | | | offsets become too large for 32-bit" This reverts commit r316805. llvm-svn: 316813
* Add support for writing 64-bit symbol tables for archives when offsets ↵Jake Ehrlich2017-10-271-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
* Pre-compute the tail of the archiveRafael Espindola2017-10-031-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
* [Support] Rename tool_output_file to ToolOutputFile, NFCReid Kleckner2017-09-231-1/+1
| | | | | | | This class isn't similar to anything from the STL, so it shouldn't use the STL naming conventions. llvm-svn: 314050
* Move code to a helper function. NFC.Rafael Espindola2017-09-221-7/+13
| | | | | | Part of a patch by Jake Ehrlich! llvm-svn: 314012
* llvm-ar: align the first archive member consistently.Rafael Espindola2017-09-221-3/+5
| | | | | | | Before we were aligning the member after the symbol table to 4 but other members to 8. llvm-svn: 314010
* llvm-ar: Don't add an unnecessary alignment in gnu mode.Rafael Espindola2017-09-221-1/+2
| | | | | | | This is mostly for getting stricter testing in preparation for future changes. llvm-svn: 314000
* Convert the archive writer to use Error.Rafael Espindola2017-09-211-13/+13
| | | | | | This found one place in lld that was not checking the error. llvm-svn: 313937
* Use raw_ostream in functions that don't need to seek. NFC.Rafael Espindola2017-09-211-5/+5
| | | | llvm-svn: 313935
* Simplify the logic for truncating UID and GID. NFC.Rafael Espindola2017-09-211-12/+9
| | | | llvm-svn: 313933
* Use ArrayRef. NFC.Rafael Espindola2017-09-211-1/+1
| | | | llvm-svn: 313895
* Rename K_MIPS64 to K_GNU64Jake Ehrlich2017-09-201-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
* Simplify writeArchive return type.Rui Ueyama2017-08-301-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
* llvm: add llvm-dlltool support to the archiverMartell Malone2017-07-181-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
* Revert r308329: llvm: add llvm-dlltool support to the archiverRui Ueyama2017-07-181-2/+1
| | | | | | This reverts commit r308329 because it broke buildbots. llvm-svn: 308374
* llvm: add llvm-dlltool support to the archiverMartell Malone2017-07-181-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
* [llvm-ar] Make llvm-lib behave more like the MSVC archiverReid Kleckner2017-06-121-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
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-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
* ArchiveWriter: Remove unused variables. NFC.Peter Collingbourne2017-03-161-4/+0
| | | | llvm-svn: 297987
* Archives require a symbol table on Solaris, even if empty.Rafael Espindola2017-03-141-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
* Move llvm_unreachable out of switch.Rafael Espindola2017-02-221-2/+5
| | | | | | | This should make gcc happy and still produce a clang warning if we add another value to the enum. llvm-svn: 295865
* Fix -Wcovered-switch-default.Rui Ueyama2017-02-221-3/+1
| | | | llvm-svn: 295799
* Don't modify archive members unless really needed.Rafael Espindola2017-02-211-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
* Object: pad out BSD archive members to 8-bytesSaleem Abdulrasool2017-02-091-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
* Object: add a comment explaining a divergenceSaleem Abdulrasool2017-02-091-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
OpenPOWER on IntegriCloud