summaryrefslogtreecommitdiff
path: root/llvm/tools/dsymutil/DebugMap.cpp
AgeCommit message (Collapse)Author
2025-08-29[llvm] Support building with c++23 (#154372)Kyle Krüger
closes #154331 This PR addresses all minimum changes needed to compile LLVM and MLIR with the c++23 standard. It is a work in progress and to be reviewed for better methods of handling the parts of the build broken by c++23.
2025-04-08[dsymutil] Avoid copying binary swiftmodules built from textualAdrian Prantl
.swiftinterface files into the dSYM bundle. These typically come only from the SDK (since textual interfaces require library evolution) and thus are a waste of space to copy into the bundle. The information about this is being parsed out of the control block, which means duplicating 5 constants from the Swift frontend. If a file cannot be parsed, dsymutil errs on the side of copying the file anyway. rdar://138186524 Relanding with additional linker dependency and moving the test into the right target subdirectory.
2025-04-08Revert "[dsymutil] Avoid copying binary swiftmodules built from textual"Adrian Prantl
This reverts commit 39ace8a63012af7d6ad7bf065c233fd3d5df44a3. while investigating Linux bot failures.
2025-04-08[dsymutil] Avoid copying binary swiftmodules built from textual (#134719)Adrian Prantl
.swiftinterface files into the dSYM bundle. These typically come only from the SDK (since textual interfaces require library evolution) and thus are a waste of space to copy into the bundle. The information about this is being parsed out of the control block, which means duplicating 5 constants from the Swift frontend. If a file cannot be parsed, dsymutil errs on the side of copying the file anyway. rdar://138186524
2024-10-22[dsymutil] Share one BinaryHolder between debug map parsing & linking (#113234)Jonas Devlieghere
I (re)discovered that dsymutil was instantiating two BinaryHolders: one for parsing the debug map and one for linking. That really defeats the purpose of the BinaryHolder as it serves as a cache. Fix the issue and remove an old FIXME.
2023-12-09[ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)Kazu Hirata
This patch renames {starts,ends}with to {starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. Since there are only a handful of occurrences, this patch skips the deprecation phase and simply renames them.
2023-10-26Reland [dsymutil] Add support for mergeable libraries (#70256)Alpha Abdoulaye
Reland https://reviews.llvm.org/D158124 Fixed `-fpermissive` error reported by gcc only.
2023-10-24Revert "[dsymutil] Add support for mergeable libraries"Philip Reames
This reverts commit 122c89b271af30b86536cad7bac64ea9c56615ed. Change does not build, with errors such as: In file included from ../llvm-project/llvm/tools/dsymutil/DebugMap.h:24, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:60:17: error: declaration of ‘llvm::dsymutil::SymbolMapping llvm::dsymutil::ValidReloc::SymbolMapping’ changes meaning of ‘SymbolMapping’ [-fpermissive] 60 | SymbolMapping SymbolMapping; | ^~~~~~~~~~~~~ ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:36:8: note: ‘SymbolMapping’ declared here as ‘struct llvm::dsymutil::SymbolMapping’ 36 | struct SymbolMapping { | ^~~~~~~~~~~~~ In file included from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/DebugMap.h:198:32: error: declaration of ‘std::optional<llvm::dsymutil::RelocationMap> llvm::dsymutil::DebugMapObject::RelocationMap’ changes meaning of ‘RelocationMap’ [-fpermissive] 198 | std::optional<RelocationMap> RelocationMap; | ^~~~~~~~~~~~~ In file included from ../llvm-project/llvm/tools/dsymutil/DebugMap.h:24, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:76:7: note: ‘RelocationMap’ declared here as ‘class llvm::dsymutil::RelocationMap’ 76 | class RelocationMap { | ^~~~~~~~~~~~~
2023-10-24[dsymutil] Add support for mergeable librariesAlpha Abdoulaye
This adds support in dsymutil for mergeable libraries [1]. dsymutil reads a new stab emitted by ld, allowing it to operate on dynamic libraries instead of object files. It also now loads the DWARF files associated to the libraries, and build the debug map for each binary from the list of symbols exported by the library. For each Debug Map Object, there is a new associated Relocation Map which is serialized from the information retrieved in the original debug_info (or debug_addr) section of the .o file. The final DWARF file has multiple compile units, so the offsets information of the relocations are adjusted relatively to the compile unit they will end up belonging to, inside the final linked DWARF file. [1] https://developer.apple.com/documentation/xcode/configuring-your-project-to-use-mergeable-libraries Differential revision: https://reviews.llvm.org/D158124
2023-10-22[llvm] Stop including llvm/ADT/iterator_range.h (NFC)Kazu Hirata
Identified with misc-include-cleaner.
2023-07-19[dsymutil] Sort entries in YamlDMO to stabilize print orderFangrui Song
Similar to the llvm::sort call in DebugMapObject::print.
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2022-12-07[llvm] Don't include Optional.h (NFC)Kazu Hirata
These source files no longer use Optional<T>. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06[YAML] Convert Optional to std::optionalKrzysztof Parzyszek
2022-06-04Use llvm::less_first (NFC)Kazu Hirata
2022-05-27Revert "[llvm][clang][bolt][NFC] Use llvm::less_first() when applicable"Balazs Benics
This reverts commit 3988bd13988aad72ec979beb2361e8738584926b. Did not build on this bot: https://lab.llvm.org/buildbot#builders/215/builds/6372 /usr/include/c++/9/bits/predefined_ops.h:177:11: error: no match for call to ‘(llvm::less_first) (std::pair<long unsigned int, llvm::bolt::BinaryBasicBlock*>&, const std::pair<long unsigned int, std::nullptr_t>&)’ 177 | { return bool(_M_comp(*__it, __val)); }
2022-05-27[llvm][clang][bolt][NFC] Use llvm::less_first() when applicableBalazs Benics
One could reuse this functor instead of rolling out your own version. There were a couple other cases where the code was similar, but not quite the same, such as it might have an assertion in the lambda or other constructs. Thus, I've not touched any of those, as it might change the behavior in some way. As per https://discourse.llvm.org/t/submitting-simple-nfc-patches/62640/3?u=steakhal Chris Lattner > LLVM intentionally has a “yes, you can apply common sense judgement to > things” policy when it comes to code review. If you are doing mechanical > patches (e.g. adopting less_first) that apply to the entire monorepo, > then you don’t need everyone in the monorepo to sign off on it. Having > some +1 validation from someone is useful, but you don’t need everyone > whose code you touch to weigh in. Differential Revision: https://reviews.llvm.org/D126068
2021-01-09[llvm] Drop unnecessary make_range (NFC)Kazu Hirata
2020-05-04[dsymutil] Thread the VFS through dsymutil (NFC)Jonas Devlieghere
This patch threads the virtual file system through dsymutil. Currently there is no good way to find out exactly what files are necessary in order to reproduce a dsymutil link, at least not without knowledge of how dsymutil's internals. My motivation for this change is to add lightweight "reproducers" that automatically gather the input object files through the FileCollectorFileSystem. The files together with the YAML mapping will allow us to transparently reproduce a dsymutil link, even without having to mess with the OSO path prefix. Differential revision: https://reviews.llvm.org/D79376
2020-05-02[Object] Change ObjectFile::getSymbolValue() return type to Expected<uint64_t>Xing GUO
Summary: In D77860, we have changed `getSymbolFlags()` return type to `Expected<uint32_t>`. This change helps bubble the error further up the stack. Reviewers: jhenderson, grimar, JDevlieghere, MaskRay Reviewed By: jhenderson Subscribers: hiraditya, MaskRay, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79075
2020-04-18[Object] Change uint32_t getSymbolFlags() to Expected<uint32_t> ↵vgxbj
getSymbolFlags(). This change enables getSymbolFlags() to return errors which benefit error reporting in clients. Differential Revision: https://reviews.llvm.org/D77860
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
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-09-30Use the container form llvm::sort(C, ...)Fangrui Song
There are a few leftovers in rL343163 which span two lines. This commit changes these llvm::sort(C.begin(), C.end, ...) to llvm::sort(C, ...) llvm-svn: 343426
2018-06-29[dsymutil] Make the CachedBinaryHolder the defaultJonas Devlieghere
Replaces all uses of the old binary holder with its cached variant. Differential revision: https://reviews.llvm.org/D48770 llvm-svn: 335991
2018-06-27[dsymutil] Move abstractions into separate files (NFC)Jonas Devlieghere
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
2018-04-14[Support] Add convenience functions to WithColor. NFC.Jonas Devlieghere
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
2018-04-01[tools] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang
Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. Reviewers: JDevlieghere, zturner, echristo, dberris, friss Reviewed By: echristo Subscribers: gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D45141 llvm-svn: 328943
2018-03-18[dsymutil] Rename llvm-dsymutil -> dsymutilJonas Devlieghere
Now that almost all functionality of Apple's dsymutil has been upstreamed, the open source variant can be used as a drop in replacement. Hence we feel it's no longer necessary to have the llvm prefix. Differential revision: https://reviews.llvm.org/D44527 llvm-svn: 327790
2018-03-13[dsymutil] Unify error handling outside DwarfLinker.Jonas Devlieghere
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
2018-02-22[dsymutil] Fix typos and formatting. NFC.Jonas Devlieghere
Some over-due gardening: this fixes a bunch of typos and makes the formatting consistent with LLVM's style guide. llvm-svn: 325768
2017-11-01[dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You ↵Eugene Zelenko
Use warnings; other minor fixes (NFC). llvm-svn: 317123
2017-10-06[llvm-dsymutil] Add support for __swift_ast MachO DWARF sectionFrancis Ricci
Summary: Xcode's dsymutil emits a __swift_ast DWARF section, which is required for debugging, and which contains a byte-for-byte dump of the swiftmodule file. Add this feature to llvm-dsymutil. Tested with `gobjdump --dwarf=info -s`, by verifying that the contents of `__DWARF.__swift_ast` match between Xcode's dsymutil and llvm-dsymutil (Xcode's dwarfdump and llvm-dwarfdump don't currently recognize the __swift_ast section). Reviewers: aprantl, friss Subscribers: llvm-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D38504 llvm-svn: 315066
2017-10-05Revert "[llvm-dsymutil] Add support for __swift_ast MachO DWARF section"Francis Ricci
Breaks aarch64 builders This reverts commit r315014. llvm-svn: 315034
2017-10-05[llvm-dsymutil] Add support for __swift_ast MachO DWARF sectionFrancis Ricci
Summary: Xcode's dsymutil emits a __swift_ast DWARF section, which is required for debugging, and which contains a byte-for-byte dump of the swiftmodule file. Add this feature to llvm-dsymutil. Tested with `gobjdump --dwarf=info -s`, by verifying that the contents of `__DWARF.__swift_ast` match between Xcode's dsymutil and llvm-dsymutil (Xcode's dwarfdump and llvm-dwarfdump don't currently recognize the __swift_ast section). Reviewers: aprantl, friss Subscribers: llvm-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D38504 llvm-svn: 315014
2017-10-05Revert "[llvm-dsymutil] Add support for __swift_ast MachO DWARF section"Francis Ricci
This reverts commit r315004, because of a failing test on non-apple platforms llvm-svn: 315009
2017-10-05[llvm-dsymutil] Add support for __swift_ast MachO DWARF sectionFrancis Ricci
Summary: Xcode's dsymutil emits a __swift_ast DWARF section, which is required for debugging, and which contains a byte-for-byte dump of the swiftmodule file. Add this feature to llvm-dsymutil. Tested with `gobjdump --dwarf=info -s`, by verifying that the contents of `__DWARF.__swift_ast` match between Xcode's dsymutil and llvm-dsymutil (Xcode's dwarfdump and llvm-dwarfdump don't currently recognize the __swift_ast section). Reviewers: aprantl, friss Subscribers: llvm-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D38504 llvm-svn: 315004
2016-11-09[dsymutil] Replace TimeValue with TimePointPavel Labath
Summary: All changes are pretty straight-forward. I chose to use TimePoints with second precision, as that is all that seems to be required here. Reviewers: friss, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25908 llvm-svn: 286358
2016-04-20Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby
llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
2016-01-31[dsymutil] Fix handling of common symbols.Frederic Riss
llvm-dsymutil was misinterpreting the value of common symbols as their address when it actually contains their size. This didn't impact llvm-dsymutil's ability to link the debug information for common symbols because these are always found by name and not by address. Things could however go wrong when the size of a common object matched the object file address of another symbol. Depending on the link order of the symbols the common object might incorrectly evict this other object from the address to symbol mapping, and then link the evicted symbol with a wrong binary address. Use the new ability to have symbols without an object file address to fix this. llvm-svn: 259318
2016-01-31[dsymutil] Allow debug map mappings with no object file address. NFCFrederic Riss
This change just changes the data structure that ties symbol names, object file address and linked binary addresses to accept mappings with no object file address. Such symbol mappings are not fed into the debug map yet, so this patch is NFC. A subsequent patch will make use of this functionality for common symbols. llvm-svn: 259317
2015-08-26[dsymutil] Store an optional BinaryPath in the debug map.Frederic Riss
llvm-dsymutil needs to emit dSYM companion bundles. These are binary files that replicate some of the orignal binary file properties (sections and symbols). To get acces to these properties, pass the binary path in the debug map. llvm-svn: 246011
2015-08-05[dsymutil] Implement support for handling mach-o universal binaries as main ↵Frederic Riss
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
2015-07-24[dsymutil] Implement support for universal mach-o object files.Frederic Riss
This patch allows llvm-dsymutil to read universal (aka fat) macho object files and archives. The patch touches nearly everything in the BinaryHolder, but it is fairly mechinical: the methods that returned MemoryBufferRefs or ObjectFiles now return a vector of those, and the high-level access function takes a triple argument to select the architecture. There is no support yet for handling fat executables and thus no support for writing fat object files. llvm-svn: 243096
2015-07-22[dsymutil] Check archive members timestamps.Frederic Riss
The debug map contains the timestamp of the object files in references. We do not check these in the general case, but it's really useful if you have archives where different versions of an object file have been appended. This allows llvm-dsymutil to find the right one. llvm-svn: 242965
2015-07-07Delete UnknownAddress. It is a perfectly valid symbol value.Rafael Espindola
getSymbolValue now returns a value that in convenient for most callers: * 0 for undefined * symbol size for common symbols * offset/address for symbols the rest Code that needs something more specific can check getSymbolFlags. llvm-svn: 241605
2015-07-07Common symbols don't have a value.Rafael Espindola
At least not in the interface exposed by ObjectFile. This matches what ELF and COFF implement. Adjust existing code that was expecting them to have values. No overall functionality change intended. Another option would be to change the interface and the ELF and COFF implementations to say that the value of a common symbol is its size. llvm-svn: 241593
2015-07-03Replace a few more MachO only uses of getSymbolAddress.Rafael Espindola
llvm-svn: 241365