summaryrefslogtreecommitdiffstats
path: root/llvm/tools/dsymutil
Commit message (Collapse)AuthorAgeFilesLines
* [Dsymutil][Debuginfo][NFC] #3 Refactor dsymutil to separate DWARF optimizing ↵Alexey Lapshin2020-01-134-54/+101
| | | | | | | | | | | | | | | | | | | | | | | | part. Summary: This is the next portion of patches for dsymutil. Create DwarfEmitter interface to generate all debug info tables. Put DwarfEmitter into DwarfLinker library and make tools/dsymutil/DwarfStreamer to be child of DwarfEmitter. It passes check-all testing. MD5 checksum for clang .dSYM bundle matches for the dsymutil with/without that patch. Reviewers: JDevlieghere, friss, dblaikie, aprantl Reviewed By: JDevlieghere Subscribers: merge_guards_bot, hiraditya, thegameg, probinson, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D72476
* [Dsymutil][Debuginfo][NFC] Reland: Refactor dsymutil to separate DWARF ↵Alexey Lapshin2020-01-0810-1048/+193
| | | | | | | | | | | | | | | | | | | | | | optimizing part. #2. Summary: This patch relands D71271. The problem with D71271 is that it has cyclic dependency: CodeGen->AsmPrinter->DebugInfoDWARF->CodeGen. To avoid cyclic dependency this patch puts implementation for DWARFOptimizer into separate library: lib/DWARFLinker. Thus the difference between this patch and D71271 is in that DWARFOptimizer renamed into DWARFLinker and it`s files are put into lib/DWARFLinker. Reviewers: JDevlieghere, friss, dblaikie, aprantl Reviewed By: JDevlieghere Subscribers: thegameg, merge_guards_bot, probinson, mgorny, hiraditya, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D71839
* [Remarks] Warn if a remark file is not found when processing static archivesFrancis Visoiu Mistrih2020-01-031-3/+33
| | | | | | | | | | | Static archives contain object files which contain sections pointing to external remark files. When static archives are shipped without the remark files, dsymutil shouldn't generate an error. Instead, generate a warning to inform the user that remarks for that library won't be available in the .dSYM.
* Temporarily Revert "[Dsymutil][Debuginfo][NFC] Refactor dsymutil to separate ↵Eric Christopher2019-12-199-82/+933
| | | | | | | | | | | DWARF optimizing part 2." as it causes a layering violation/dependency cycle: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp -> llvm/DebugInfo/DWARF/DWARFExpression.h llvm/include/llvm/DebugInfo/DWARF/DWARFOptimizer.h -> llvm/CodeGen/NonRelocatableStringpool.h This reverts commit abc7f6800df8a1f40e1e2c9ccce826abb0208284.
* [Dsymutil][Debuginfo][NFC] Refactor dsymutil to separate DWARF optimizing ↵Alexey Lapshin2019-12-199-933/+82
| | | | | | | | | | | part 2. That patch is extracted from the D70709. It moves CompileUnit, DeclContext into llvm/DebugInfo/DWARF. It also adds new file DWARFOptimizer with AddressesMap class. AddressesMap generalizes functionality from RelocationManager. Differential Revision: https://reviews.llvm.org/D71271
* Fix building shared libraries broken by 8e48e8e3e32.Alexey Lapshin2019-12-062-1/+2
|
* [Dsymutil][NFC] Move NonRelocatableStringpool into common CodeGen folder.Alexey Lapshin2019-12-067-153/+12
| | | | | | | 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
* [dsymutil] Remove recursion from lookForChildDIEsToKeep (2/2) (NFC)Jonas Devlieghere2019-12-041-74/+139
| | | | | | | | | | | | | | | | | The functions lookForDIEsToKeep and keepDIEAndDependencies are mutually recursive and can cause a stackoverflow for large projects. While this has always been the case, it became a bigger issue when we parallelized dsymutil, because threads get only a fraction of the stack space. This patch removes the final recursive call from lookForDIEsToKeep. The call was used to look at the current DIE's parent chain and mark everything as kept. This was tested by running dsymutil on clang built in debug (both with and without modules) and comparing the MD5 hash of the generated dSYM companion file. Differential revision: https://reviews.llvm.org/D70994
* [dsymutil] Remove recursion from lookForChildDIEsToKeep (1/2) (NFC)Jonas Devlieghere2019-12-042-172/+206
| | | | | | | | | | | | | | | | | | | | | | | | | The functions lookForDIEsToKeep and keepDIEAndDependencies are mutually recursive and can cause a stackoverflow for large projects. While this has always been the case, it became a bigger issue when we parallelized dsymutil, because threads get only a fraction of the stack space. In an attempt to tackle this issue, we removed part of the recursion in r338536 by introducing a worklist. Processing of child DIEs was no longer recursive. However, we still received bug reports where we'd run out of stack space. This patch removes another recursive call from lookForDIEsToKeep. The call was used to look at DIEs that reference the current DIE. To make this possible, we inlined keepDIEAndDependencies and added this work to the existing worklist. Because the function is not tail recursive, we needed to add two more types of worklist entries to perform the subsequent work. This was tested by running dsymutil on clang built in debug (both with and without modules) and comparing the MD5 hash of the generated dSYM companion file. Differential revision: https://reviews.llvm.org/D70990
* [dsymutil] Support --out (NFC)Jonas Devlieghere2019-12-031-1/+1
| | | | Seems like this got lost during the libOption conversion.
* [dsymutil] Add support for linking remarksFrancis Visoiu Mistrih2019-11-015-1/+132
| | | | | | | | | | | | | | | | | | | | This adds support to dsymutil for linking remark files and placing them in the final .dSYM bundle. The result will be placed in: * a.out.dSYM/Contents/Resources/Remarks/a.out or * a.out.dSYM/Contents/Resources/Remarks/a.out-<arch> for universal binaries When multi-threaded, this runs a third thread which loops over all the object files and parses remarks as it finds __remarks sections. Testing this involves running dsymutil on pre-built binaries and object files, then running llvm-bcanalyzer on the final result to check for remarks. Differential Revision: https://reviews.llvm.org/D69142
* [dsymutil] Add DW_TAG_common_block to dieNeedsChildrenToBeMeaningfulJonas Devlieghere2019-11-011-3/+4
| | | | | | | | Ensure we walk the children of common blocks when deciding what DIEs to keep. Otherwise we might incorrectly discard them leading to missing variables in the linked debug info. This also sorts the list of DW_TAGs alphabetically.
* [Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin2019-10-231-2/+2
| | | | | | | | | | MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
* [dsymutil] Print warning/error for unknown/missing arguments.Jonas Devlieghere2019-10-161-0/+10
| | | | | | | | | After changing dsymutil to use libOption, we lost error reporting for missing required arguments (input files). Additionally, we stopped complaining about unknown arguments. This patch fixes both and adds a test. llvm-svn: 375044
* [dsymutil] Support and relocate base address selection entries for debug_locJonas Devlieghere2019-10-151-0/+12
| | | | | | | | | | | | | | | Since r374600 clang emits base address selection entries. Currently dsymutil does not support these entries and incorrectly interprets them as location list entries. This patch adds support for base address selection entries in dsymutil and makes sure they are relocated correctly. Thanks to Dave for coming up with the test case! Differential revision: https://reviews.llvm.org/D69005 llvm-svn: 374957
* [dsymutil] Move CommonSymbols.clear() in resetParserState.Jonas Devlieghere2019-10-101-1/+1
| | | | | | | This seems like a more natural place to clear the vector, especially since this method is clearing other data structures as well. llvm-svn: 374378
* Re-land "[dsymutil] Fix handling of common symbols in multiple object files."Jonas Devlieghere2019-10-091-2/+33
| | | | | | | | The original patch got reverted because it hit a long-standing legacy issue on Windows that prevents files from being named `com`. Thanks Kristina & Jeremy for pointing this out. llvm-svn: 374178
* Revert r374139, "[dsymutil] Fix handling of common symbols in multiple ↵Jeremy Morse2019-10-091-33/+2
| | | | | | | | | object files." The added test files ("com", "com1.o", "com2.o") are reserved names on Windows, and makes 'git checkout' fail with a filesystem error. llvm-svn: 374144
* [dsymutil] Fix handling of common symbols in multiple object files.Jonas Devlieghere2019-10-091-2/+33
| | | | | | | | | | | | | For common symbols the linker emits only a single symbol entry in the debug map. This caused dsymutil to not relocate common symbols when linking DWARF coming form object files that did not have this entry. This patch fixes that by keeping track of common symbols in the object files and synthesizing a debug map entry for them using the address from the main binary. Differential revision: https://reviews.llvm.org/D68680 llvm-svn: 374139
* [dsymutil] Improve verbose output (NFC)Jonas Devlieghere2019-10-081-8/+11
| | | | | | | | | | | | The verbose output for finding relocations assumed that we'd always dump the DIE after (which starts with a newline) and therefore didn't include one itself. However, this isn't always true, leading to garbled output. This patch adds a newline to the verbose output and adds a line that says that the DIE is being kept (which isn't obvious otherwise). It also adds a 0x prefix to the relocations. llvm-svn: 374123
* [dsymutil] Fix stack-use-after-scopeJonas Devlieghere2019-10-041-2/+2
| | | | | | | | | | The lambda is taking the stack-allocated Verify boolean by reference and it would go out of scope on the next iteration. Moving it out of the loop should fix the issue. Fixes https://bugs.llvm.org/show_bug.cgi?id=43549 llvm-svn: 373683
* [dsymutil] Don't overload LinkOptions.Jonas Devlieghere2019-10-031-35/+34
| | | | | | | | | This should fix the build bots: error: declaration of ‘llvm::dsymutil::LinkOptions DsymutilOptions::LinkOptions’ [-fpermissive] llvm-svn: 373640
* Fix build failure with GCC on identifier reusing.Michael Liao2019-10-031-1/+1
| | | | | | | - GCC is different from clang and other compilers on that. https://godbolt.org/z/CeQE1V llvm-svn: 373633
* [dsymutil] Improve consistency by removing redundant namespaces (NFC)Jonas Devlieghere2019-10-031-44/+40
| | | | | | | The dsymutil implementation file has a using-directive for the llvm namespace. This patch just removes redundant namespace qualifiers. llvm-svn: 373623
* [dsymutil] Tablegenify option parsingJonas Devlieghere2019-10-033-297/+443
| | | | | | | | | | | | | | | | | | | This patch reimplements command line option parsing in dsymutil with Tablegen and libOption. The main motivation for this change is to prevent clashes with other cl::opt options defined in llvm. Although it's a bit more heavyweight, it has some nice advantages such as no global static initializers and better separation between the code and the option definitions. I also used this opportunity to improve how dsymutil deals with incompatible options. Instead of having checks spread across the code, everything is now grouped together in verifyOptions. The fact that the options are no longer global means that we need to pass them around a bit more, but I think it's worth the trade-off. Differential revision: https://reviews.llvm.org/D68361 llvm-svn: 373622
* [Alignment][NFC] Remove unneeded llvm:: scoping on Align typesGuillaume Chatelet2019-09-271-2/+2
| | | | llvm-svn: 373081
* [Alignment] Introduce llvm::Align to MCSectionGuillaume Chatelet2019-09-131-1/+1
| | | | | | | | | | | | | | | | | 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 Subscribers: arsenm, sdardis, jvesely, nhaehnle, sbc100, hiraditya, aheejin, jrtc27, atanasyan, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67486 llvm-svn: 371831
* [Alignment] Move OffsetToAlignment to Alignment.hGuillaume Chatelet2019-09-121-1/+1
| | | | | | | | | | | | | | | | | 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] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-154-7/+7
| | | | | | | | 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
* Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar2019-08-142-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expected<>" Changes: no changes. A fix for the clang code will be landed right on top. Original commit message: SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368826
* Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar2019-08-142-10/+2
| | | | | | | | Expected<>" It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455 llvm-svn: 368813
* [llvm/Object] - Convert SectionRef::getName() to return Expected<>George Rimar2019-08-142-2/+10
| | | | | | | | | | | | | | | | | | | | | | | SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368812
* DebugInfo/DWARF: Normalize DWARFObject members on the DWARF spec section namesDavid Blaikie2019-08-071-3/+3
| | | | | | | | | Some of these names were abbreviated, some were not, some pluralised, some not. Made the API difficult to use - since it's an exact 1:1 mapping to the DWARF sections - use those names (changing underscore separation for camel casing). llvm-svn: 368189
* Switch LLVM to use 64-bit offsets (2/5)Igor Kudrin2019-08-064-36/+36
| | | | | | | | | This updates all libraries and tools in LLVM Core to use 64-bit offsets which directly or indirectly come to DataExtractor. Differential Revision: https://reviews.llvm.org/D65638 llvm-svn: 368014
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-2/+2
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [dsymutil] Fix heap-use-after-free related to the LinkOptions.Jonas Devlieghere2019-08-011-5/+6
| | | | | | | | | In r367348, I changed dsymutil to pass the LinkOptions by value isntead of by const reference. However, the options were still captured by reference in the LinkLambda. This patch fixes that by passing them in by value. llvm-svn: 367635
* [dsymutil] Pass LinkOptions by value instead of const ref.Jonas Devlieghere2019-07-303-6/+6
| | | | | | | | | | | | | When looping over the difference architectures in a fat binary, we modify the link options before dispatching the link step to a different thread. Passing the options by cont reference is not thread safe, as we might modify its fields before the whole sturct is copied over. Given that the link options are already stored in the DwarfLinker, we can easily fix this by passing a copy of the link options instead of a reference, which would just get copied later on. llvm-svn: 367348
* [DebugInfo] Generate fixups as emitting DWARF .debug_frame/.eh_frame.Hsiangkai Wang2019-07-191-1/+1
| | | | | | | | | | | | | It is necessary to generate fixups in .debug_frame or .eh_frame as relaxation is enabled due to the address delta may be changed after relaxation. There is an opcode with 6-bits data in debug frame encoding. So, we also need 6-bits fixup types. Differential Revision: https://reviews.llvm.org/D58335 llvm-svn: 366524
* Revert "[DebugInfo] Generate fixups as emitting DWARF .debug_frame/.eh_frame."Hsiangkai Wang2019-07-181-1/+1
| | | | | | This reverts commit 17e3cbf5fe656483d9016d0ba9e1d0cd8629379e. llvm-svn: 366444
* [DebugInfo] Generate fixups as emitting DWARF .debug_frame/.eh_frame.Hsiangkai Wang2019-07-181-1/+1
| | | | | | | | | | | | | It is necessary to generate fixups in .debug_frame or .eh_frame as relaxation is enabled due to the address delta may be changed after relaxation. There is an opcode with 6-bits data in debug frame encoding. So, we also need 6-bits fixup types. Differential Revision: https://reviews.llvm.org/D58335 llvm-svn: 366442
* Cleanup: llvm::bsearch -> llvm::partition_point after r364719Fangrui Song2019-06-301-2/+2
| | | | llvm-svn: 364720
* Simplify std::lower_bound with llvm::{bsearch,lower_bound}. NFCFangrui Song2019-06-211-7/+5
| | | | llvm-svn: 364006
* [dsymutil] Remove stale comment (NFC)Jonas Devlieghere2019-06-101-1/+0
| | | | | | The comment was no longer relevant after r362621. llvm-svn: 363008
* [dsymutil] Use the number of threads specified.Jonas Devlieghere2019-06-071-3/+5
| | | | | | | | Before this patch we used either a single thread, or the number of hardware threads available, effectively ignoring the number of threads specified on the command line. llvm-svn: 362815
* [dsymutil] Support more than 4 architecturesJonas Devlieghere2019-06-052-2/+3
| | | | | | | | | | | | | | 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
* [dwarfdump] Add flag to limit the number of parents DIEsJonas Devlieghere2019-05-241-8/+10
| | | | | | | | | This adds `-parent-recurse-depth` which limits the number of parent DIEs being dumped. Differential revision: https://reviews.llvm.org/D62359 llvm-svn: 361671
* Break false dependencies on target librariesDaniel Sanders2019-05-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For the most part this consists of replacing ${LLVM_TARGETS_TO_BUILD} with some combination of AllTargets* so that they depend on specific components of a target backend rather than all of it. The overall effect of this is that, for example, tools like opt no longer falsely depend on the disassembler, while tools like llvm-ar no longer depend on the code generator. There's a couple quirks to point out here: * AllTargetsCodeGens is a bit more prevalent than expected. Tools like dsymutil seem to need it which I was surprised by. * llvm-xray linked to all the backends but doesn't seem to need any of them. It builds and passes the tests so that seems to be correct. * I left gold out as it's not built when binutils is not available so I'm unable to test it Reviewers: bogner, JDevlieghere Reviewed By: bogner Subscribers: mehdi_amini, mgorny, steven_wu, dexonsmith, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62331 llvm-svn: 361567
* [Dsymutil] Remove redundant argument (NFC)Jonas Devlieghere2019-05-213-7/+5
| | | | | | | The dwarf streamer already holds a copy of the link options, so there's no need to pass them as an argument. llvm-svn: 361276
* Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song2019-05-162-7/+13
| | | | | | | | | | | | Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
* Revert r360876 "[Object] Change object::SectionRef::getContents() to return ↵Hans Wennborg2019-05-162-13/+7
| | | | | | | | | | | | Expected<StringRef>" It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
OpenPOWER on IntegriCloud