summaryrefslogtreecommitdiffstats
path: root/llvm/tools/dsymutil/MachOUtils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Dsymutil][NFC] Move NonRelocatableStringpool into common CodeGen folder.Alexey Lapshin2019-12-061-2/+7
| | | | | | | That refactoring moves NonRelocatableStringpool into common CodeGen folder. So that NonRelocatableStringpool could be used not only inside dsymutil. Differential Revision: https://reviews.llvm.org/D71068
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-1/+1
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* [dsymutil] Support more than 4 architecturesJonas Devlieghere2019-06-051-1/+1
| | | | | | | | | | | | | | When running dsymutil on a fat binary, we use temporary files in a small vector of size four. When processing more than 4 architectures, this resulted in a user-after-move, because the temporary files got moved to the heap. Instead of storing an optional temp file, we now use a unique pointer, so the location of the actual temp file doesn't change. We could test this by checking in 5 binaries for 5 different architectures, but this seems wasteful, especially since the number of elements in the small vector is arbitrary. llvm-svn: 362621
* 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
* [dsymutil] Upstream unobfuscation logic.Jonas Devlieghere2019-01-071-3/+3
| | | | | | | | | | The unobufscation support for BCSymbolMaps was the last piece of code that hasn't been upstreamed yet. This patch contains a reworked version of the existing code and relevant tests. Differential revision: https://reviews.llvm.org/D56346 llvm-svn: 350580
* Make dsymutil more robust when parsing load commands.Adrian Prantl2018-11-131-14/+19
| | | | | | rdar://problem/45883463 llvm-svn: 346815
* [dsymutil] Copy the LC_BUILD_VERSION load command into the companion binary.Adrian Prantl2018-11-081-14/+29
| | | | | | | | | | | | | LC_BUILD_VERSION contains platform information that is useful for LLDB to match up dSYM bundles with binaries. This patch copies the load command over into the dSYM. rdar://problem/44145175 rdar://problem/45883463 Differential Revision: https://reviews.llvm.org/D54233 llvm-svn: 346412
* [DebugInfo] Reduce debug_str_offsets section sizePavel Labath2018-08-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The accelerator tables use the debug_str section to store their strings. However, they do not support the indirect method of access that is available for the debug_info section (DW_FORM_strx et al.). Currently our code is assuming that all strings can/will be referenced indirectly, and puts all of them into the debug_str_offsets section. This is generally true for regular (unsplit) dwarf, but in the DWO case, most of the strings in the debug_str section will only be used from the accelerator tables. Therefore the contents of the debug_str_offsets section will be largely unused and bloating the main executable. This patch rectifies this by teaching the DwarfStringPool to differentiate between strings accessed directly and indirectly. When a user inserts a string into the pool it has to declare whether that string will be referenced directly or not. If at least one user requsts indirect access, that string will be assigned an index ID and put into debug_str_offsets table. Otherwise, the offset table is skipped. This approach reduces the overall binary size (when compiled with -gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is shrunk by 99%). Reviewers: probinson, dblaikie, JDevlieghere Subscribers: aprantl, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D49493 llvm-svn: 339122
* [dsymutil] Simplify temporary file handling.Jonas Devlieghere2018-07-291-13/+29
| | | | | | | | | | | Dsymutil's update functionality was broken on Windows because we tried to rename a file while we're holding open handles to that file. TempFile provides a solution for this through its keep(Twine) method. This patch changes dsymutil to make use of that functionality. Differential revision: https://reviews.llvm.org/D49860 llvm-svn: 338216
* [MC] Add interface to finish pending labels.Jonas Devlieghere2018-07-101-1/+3
| | | | | | | | | | | When manually finishing the object writer in dsymutil, it's possible that there are pending labels that haven't been resolved. This results in an assertion when the assembler tries to fixup a label that doesn't have an address yet. Differential revision: https://reviews.llvm.org/D49131 llvm-svn: 336688
* [dsymutil] Make the CachedBinaryHolder the defaultJonas Devlieghere2018-06-291-8/+14
| | | | | | | | Replaces all uses of the old binary holder with its cached variant. Differential revision: https://reviews.llvm.org/D48770 llvm-svn: 335991
* [dsymutil] Move abstractions into separate files (NFC)Jonas Devlieghere2018-06-271-2/+2
| | | | | | | | | | | This patch splits off some abstractions used by dsymutil's dwarf linker and moves them into separate header and implementation files. This almost halves the number of LOC in DwarfLinker.cpp and makes it a lot easier to understand what functionality lives where. Differential revision: https://reviews.llvm.org/D48647 llvm-svn: 335749
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-121-8/+7
| | | | | | | | | | | | | | | | | | | This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
* MC: Change object writers to use endian::Writer. NFCI.Peter Collingbourne2018-05-211-16/+13
| | | | | | | | Part of PR37466. Differential Revision: https://reviews.llvm.org/D47040 llvm-svn: 332861
* MC: Change MCAssembler::writeSectionData and writeFragmentPadding to take a ↵Peter Collingbourne2018-05-211-1/+1
| | | | | | | | | | | | | | raw_ostream. NFCI. Also clean up a couple of hacks where we were writing the section contents to another stream by setting the object writer's stream, writing and setting it back. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47038 llvm-svn: 332858
* [Support] Add convenience functions to WithColor. NFC.Jonas Devlieghere2018-04-141-5/+5
| | | | | | | | | Create convenience functions for printing error, warning and note to stdout. Previously we had similar functions being used in dsymutil, but given that this pattern is so common it makes sense to make it available globally. llvm-svn: 330091
* [dsymutil] Unify error handling outside DwarfLinker.Jonas Devlieghere2018-03-131-4/+5
| | | | | | | | This is a follow-up to r327137 where we unified error handling for the DwarfLinker. This replaces calls to errs() and outs() with the appropriate ostream wrapper everywhere in dsymutil. llvm-svn: 327411
* [dsymutil] Fix typos and formatting. NFC.Jonas Devlieghere2018-02-221-14/+13
| | | | | | | Some over-due gardening: this fixes a bunch of typos and makes the formatting consistent with LLVM's style guide. llvm-svn: 325768
* [dsymutil] Make NonRelocatableStringPool a wrapper around ↵Jonas Devlieghere2018-01-241-5/+8
| | | | | | | | | | | DwarfStringPoolEntry. NFC This is needed in order to use our StringPool entries in the Apple accelerator tables. As this is NFC we rely on the existing tests for correctness. llvm-svn: 323339
* Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko2017-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
* Spelling mistakes in comments. NFCI.Simon Pilgrim2017-03-301-1/+1
| | | | | | Based on corrections mentioned in patch for clang for PR27635 llvm-svn: 299072
* [dsymutil] Fix __LINKEDIT vmsize in dsymutil upgrade pathSteven Wu2017-02-021-0/+2
| | | | | | | | | | | | | | | | Summary: dsymutil upgrade path can change the size of segment and it needs to update the vmsize of the segment to reflect the size change. rdar://problem/30290714 Reviewers: friss Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29433 llvm-svn: 293842
* Change that to include MCMachObjectWriter.hReid Kleckner2016-06-221-1/+1
| | | | llvm-svn: 273511
* Add one more missing MCObjectWriter.h includeReid Kleckner2016-06-221-0/+1
| | | | llvm-svn: 273510
* Update to use new name alignTo().Rui Ueyama2016-01-141-11/+10
| | | | llvm-svn: 257804
* [dsymutil] Try to find lipo first besides dsymutil before looking up the PATH.Frederic Riss2015-10-081-4/+6
| | | | | | | | Even if we don't have it in PATH, lipo should usually exist in the same directory as dsymutil. Keep the fallback looking up the PATH, it's very useful when testing a non-installed executable. llvm-svn: 249762
* Reapply r246012 [dsymutil] Emit real dSYM companion binaries.Frederic Riss2015-09-021-0/+426
| | | | | | | | | | | | | | | | | | | | | | | With a fix for big endian machines. Thanks to Daniel Sanders for the debugging! Original commit message: The binaries containing the linked DWARF generated by dsymutil are not standard relocatable object files like emitted did previsously. They should be dSYM companion files, which means they have a different file type in the header, but also a couple other peculiarities: - they contain the segments and sections from the original binary in their load commands, but not the actual contents. This means they get an address and a size, but their offset is always 0 (but these are not virtual sections) - they also conatin all the defined symbols from the original binary This makes MC a really bad fit to emit these kind of binaries. The approach that was used in this patch is to leverage MC's section layout for the debug sections, but to use a replacement for MachObjectWriter that lives in MachOUtils.cpp. Some of the low-level helpers from MachObjectWriter were reused too. llvm-svn: 246673
* Revert "[dsymutil] Emit real dSYM companion binaries."Frederic Riss2015-08-261-423/+0
| | | | | | | This reverts commit r246012. Some bots do not like it (mips/s390). llvm-svn: 246019
* [dsymutil] Emit real dSYM companion binaries.Frederic Riss2015-08-261-0/+423
| | | | | | | | | | | | | | | | | | | The binaries containing the linked DWARF generated by dsymutil are not standard relocatable object files like emitted did previsously. They should be dSYM companion files, which means they have a different file type in the header, but also a couple other peculiarities: - they contain the segments and sections from the original binary in their load commands, but not the actual contents. This means they get an address and a size, but their offset is always 0 (but these are not virtual sections) - they also conatin all the defined symbols from the original binary This makes MC a really bad fit to emit these kind of binaries. The approach that was used in this patch is to leverage MC's section layout for the debug sections, but to use a replacement for MachObjectWriter that lives in MachOUtils.cpp. Some of the low-level helpers from MachObjectWriter were reused too. llvm-svn: 246012
* [dsymutil] Reapply r245960.Frederic Riss2015-08-251-0/+7
| | | | | | | | | | | | | | | | | | There was an issue in the test setup because the test requires an arch that wasn't filtered by the lit.local.cfg, but given the set of bots that failed, I'm not confident this is the (only) issue. So this commit also adds more output to the test to help me track down the failure if it happens again. Original commit message: [dsymutil] Rewrite thumb triple names in user visible messages. We autodetect triples from the input file(s) while reading the mach-o debug map. As we need to create a Target from those triples, we always chose the thumb variant (because the arm variant might not be 'instantiable' eg armv7m). The user visible architecture names should still be 'arm' and not 'thumb' variants though. llvm-svn: 245988
* Revert "[dsymutil] Rewrite thumb triple names in user visible messages."Frederic Riss2015-08-251-7/+0
| | | | | | | | This reverts commit r245960. Multiple bots are failing on the new test. It seemd like llvm-dsymutil exits with an error. Investigating. llvm-svn: 245964
* [dsymutil] Rewrite thumb triple names in user visible messages.Frederic Riss2015-08-251-0/+7
| | | | | | | | | | We autodetect triples from the input file(s) while reading the mach-o debug map. As we need to create a Target from those triples, we always chose the thumb variant (because the arm variant might not be 'instantiable' eg armv7m). The user visible architecture names should still be 'arm' and not 'thumb' variants though. llvm-svn: 245960
* [dsymutil] Implement support for handling mach-o universal binaries as main ↵Frederic Riss2015-08-051-0/+86
input/output. The DWARF linker isn't touched by this, the implementation links individual files and merges them together into a fat binary by calling out to the 'lipo' utility. The main change is that the MachODebugMapParser can now return multiple debug maps for a single binary. The test just verifies that lipo would be invoked correctly, but doesn't actually generate a binary. This mimics the way clang tests its external iplatform tools integration. llvm-svn: 244087
OpenPOWER on IntegriCloud