aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/MachODump.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-05-02[Object] Change getSectionName() to return Expected<StringRef>Fangrui Song1-14/+11
Summary: It currently receives an output parameter and returns std::error_code. Expected<StringRef> fits for this purpose perfectly. Differential Revision: https://reviews.llvm.org/D61421 llvm-svn: 359774
2019-04-15[llvm-objdump] Wrap things in namespace llvmFangrui Song1-59/+52
llvm-svn: 358417
2019-04-15[llvm-objdump] Reorganize cl::opt variables and move Mach-O specifics to ↵Fangrui Song1-32/+116
MachODump.cpp llvm-svn: 358415
2019-04-09[llvm-objdump] Migrate some functions from std::error_code to ErrorFangrui Song1-4/+2
llvm-svn: 357965
2019-04-08[BinaryFormat] Update Mach-O ARM64E CPU subtype and dumpingShoaib Meenai1-0/+7
The new value is taken from <mach/machine.h> in the MacOSX10.14 SDK from Xcode 10.1. Update llvm-objdump and llvm-readobj accordingly. Differential Revision: https://reviews.llvm.org/D58636 llvm-svn: 357945
2019-04-08[llvm-objdump] Migrate relocation handling functions from error_code to ErrorFangrui Song1-6/+5
llvm-svn: 357920
2019-04-07[llvm-objdump] Simplify Expected<T> handling with unwrapOrErrorFangrui Song1-188/+100
llvm-svn: 357855
2019-04-07Change some StringRef::data() reinterpret_cast to bytes_begin() or ↵Fangrui Song1-2/+1
arrayRefFromStringRef() llvm-svn: 357852
2019-02-27[DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin1-1/+1
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
2019-02-19Revert "Revert "[llvm-objdump] Allow short options without arguments to be ↵Matthew Voss1-1/+1
grouped"" - Tests that use multiple short switches now test them grouped and ungrouped. - Ensure the output of ungrouped and grouped variants is identical Differential Revision: https://reviews.llvm.org/D57904 llvm-svn: 354375
2019-02-14Revert "[llvm-objdump] Allow short options without arguments to be grouped"Matthew Voss1-1/+1
Reverted due to failures on the llvm-hexagon-elf. This reverts commit 77e1f27476c89f65eeb496d131065177e6417f23. llvm-svn: 354002
2019-02-14[llvm-objdump] Allow short options without arguments to be groupedMatthew Voss1-1/+1
Summary: https://bugs.llvm.org/show_bug.cgi?id=31679 Reviewers: kristina, jhenderson, grimar, jakehehrlich, rupprecht Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57904 llvm-svn: 353998
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
2019-01-18[llvm-objdump] - Move getRelocationValueString and dependenices out of the ↵George Rimar1-0/+258
llvm-objdump.cpp getRelocationValueString is a dispatcher function that calls the corresponding ELF/COFF/Wasm/MachO implementations that currently live in the llvm-objdump.cpp file. These implementations better be moved to ELFDump.cpp, COFFDump.cpp and other corresponding files, to move platform specific implementation out from the common logic. The patch does that. Also, I had to move ToolSectionFilter helper and SectionFilterIterator, SectionFilter to a header to make them available across the objdump code. Differential revision: https://reviews.llvm.org/D56842 llvm-svn: 351545
2019-01-15llvm-objdump -m -D should disassemble all text segmentsMichael Trent1-2/+13
Summary: When running llvm-objdump with the -macho option objdump will by default disassemble only the __TEXT,__text section (or __TEXT_EXEC,__text when disassembling MH_KEXT_BUNDLE files). The -disassemble-all option is treated no diferently than -disassemble. This change upates llvm-objdump's MachO parsing code to disassemble all __text sections found in a file when -disassemble-all is specified. This is useful for disassembling files with more than one __text section, or when disassembling files whose __text section is not present in __TEXT. I added a lit test case that verifies "llvm-objdump -m -d" and "llvm-objdump -m -D" produce the expected results on a reference binary. I also updated the CommandGuide documentation for llvm-objdump.rst and verified it renders correctly as man and html. rdar://42899338 Reviewers: ab, pete, lhames Reviewed By: lhames Subscribers: rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56649 llvm-svn: 351238
2019-01-15[llvm-objdump] - Cleanup the code. NFCI.George Rimar1-6/+6
This is a cosmetic cleanup for the llvm-objdump code. This patch: * Renames things to match the official LLVM code style (lower case -> upper case). * Removes few obviously excessive variables. * Moves a few lines closer to the place of use, reorders the code a bit to simplify it, to avoid doing excessive returns and to avoid using 'else` after returns. I focused only on a llvm-objdump.h/llvm-objdump.cpp files. Few changes in the MachODump.cpp and COFFDump.cpp are a result of llvm-objdump.h modification. Differential revision: https://reviews.llvm.org/D56637 llvm-svn: 351171
2019-01-10[llvm-objdump][MachO] Fix error reporting after r350848 and r350849Francis Visoiu Mistrih1-3/+5
llvm-svn: 350851
2019-01-10[llvm-objdump][MachO] Use the -dsym file name when reporting errorsFrancis Visoiu Mistrih1-2/+2
Instead of using the binary filename. llvm-svn: 350849
2019-01-10[llvm-objdump][MachO] Correctly handle the llvm::Error when -dsym has errorsFrancis Visoiu Mistrih1-2/+3
In an assert build, the Error gets destroyed and we get "Program aborted due to an unhandled Error:". In release, we get an empty message. llvm-svn: 350848
2018-12-20[binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht1-9/+8
llvm-svn: 349710
2018-12-07Update the Swift version numbers reported by objdumpMichael Trent1-2/+6
Summary: Add Swift 4.1, Swift 4.2, and Swift 5 version numbers to objdump's MachODump's print_imae_info routines. rdar://46548425 Reviewers: pete, lhames, bob.wilson Reviewed By: pete, bob.wilson Subscribers: bob.wilson, llvm-commits Differential Revision: https://reviews.llvm.org/D55442 llvm-svn: 348632
2018-11-11[llvm-objdump] Use WithColor for error reportingJonas Devlieghere1-39/+53
Use helpers from Support/WithError.h to print errors. llvm-svn: 346623
2018-09-27llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song1-1/+1
Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 llvm-svn: 343163
2018-08-31[llvm-objdump] Keep the memory buffer from the dSYM alive when using -g -dsymFrancis Visoiu Mistrih1-0/+3
When using -g and -dsym, llvm-objdump opens the dsym file and keeps the MachOObjectFile alive, while the memory buffer that the MachOObjectFile was based on gets destroyed. Differential Revision: https://reviews.llvm.org/D51365 llvm-svn: 341209
2018-08-04[llvm-objdump] Remove continue after report_error which is unreachableFangrui Song1-2/+0
llvm-svn: 338951
2018-08-03objdump: Better handling of Mach-O universal binariesDave Lee1-153/+167
Summary: With Mach-O, there is a flag requirement discrepancy between working with universal binaries and thin binaries. Many flags that don't require the `-macho` flag (for example `-private-headers` and `-disassemble`) fail to work on universal binaries unless `-macho` is given. When this happens, the error message is unhelpful, stating: The file was not recognized as a valid object file. Which can lead to confusion. This change allows generic flags to be used on universal binaries with and without the `-macho` flag. This means flags that can be used for thin files can be used consistently with fat files too. To do this, the universal binary support within `ParseInputMachO()` is extracted into a new function. This new function is called directly from `DumpInput()` when the input binary is universal. Additionally the `-arch` flag validation in `ParseInputMachO()` was extracted to be reused. Reviewers: compnerd Reviewed By: compnerd Subscribers: keith, llvm-commits Differential Revision: https://reviews.llvm.org/D48702 llvm-svn: 338792
2018-07-06Reapply: "objdump: Support newer ObjC image info flags"Dave Lee1-0/+6
Summary: Add support for two additional ObjC image info flags: `IS_SIMULATED` and `HAS_CATEGORY_CLASS_PROPERTIES`. `IS_SIMULATED` indicates a Mach-O binary built for iOS simulator. `HAS_CATEGORY_CLASS_PROPERTIES` indicates a Mach-O binary built by a compiler that supports class properties in categories. Reviewers: enderby, compnerd Reviewed By: compnerd Subscribers: keith, llvm-commits Differential Revision: https://reviews.llvm.org/D48568 llvm-svn: 336411
2018-07-06Revert "objdump: Support newer ObjC image info flags"Dave Lee1-6/+0
This reverts commit 8c4cc472e7a67bd3b2b20cc4cf32d31af29bc7e9. llvm-svn: 336402
2018-07-05objdump: Support newer ObjC image info flagsDave Lee1-0/+6
Summary: Add support for two additional ObjC image info flags: `IS_SIMULATED` and `HAS_CATEGORY_CLASS_PROPERTIES`. `IS_SIMULATED` indicates a Mach-O binary built for iOS simulator. `HAS_CATEGORY_CLASS_PROPERTIES` indicates a Mach-O binary built by a compiler that supports class properties in categories. Reviewers: enderby, compnerd Reviewed By: compnerd Subscribers: keith, llvm-commits Differential Revision: https://reviews.llvm.org/D48568 llvm-svn: 336399
2018-07-05[llvm-objdump] Add --archive-headers (-a) optionPaul Semel1-5/+0
llvm-svn: 336357
2018-05-01Remove \brief commands from doxygen comments.Adrian Prantl1-1/+1
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
2018-04-19[llvm-objdump] Issue error message when object file cannot be createdGerolf Hoflehner1-4/+6
llvm-svn: 330364
2018-04-01[tools] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang1-1/+1
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-20For llvm-objdump and Mach-O files, fix the printing of module init andKevin Enderby1-9/+43
term sections from .o files to look to see if the pointers have a relocation entry and if so print the symbol name from the relocation entry. If not fall back to the existing code and use the pointer value to look up that value in the symbol table. rdar://38337506 llvm-svn: 328037
2018-03-08For llvm-objdump and Mach-O files, update the printing of some thread statesKevin Enderby1-0/+20
from core files. I tested this against the couple of core files that were getting errors about unknown thread flavors and it now produce the same output as the Xcode otool-classic(1) tool. Since the core files are huge I didn’t include them as test cases. rdar://38216356 llvm-svn: 327077
2018-02-20[llvm-objdump] Use unique_ptr to simplify memory ownershipDavid Blaikie1-34/+31
Followup to r325099/r325100 to simplify further. llvm-svn: 325612
2018-02-14Use delete[] instead of freeSerge Pavlov1-2/+2
llvm-svn: 325100
2018-02-14Use delete[] to deallocate array of charsSerge Pavlov1-2/+2
llvm-svn: 325099
2018-02-14Refactor DisassembleInfo in MachODump.cppSerge Pavlov1-83/+23
The change implements constructor of DisassembleInfo to avoid duplication of initialization code and gets rid of malloc/free where possible. Differential Revision: https://reviews.llvm.org/D43003 llvm-svn: 325098
2018-02-09llvm-objdump when printing the Objective-C meta data also prints the Swift ABIKevin Enderby1-0/+16
from the value stored in swift_version bits in the flags field in the objc_image_info struct. ABI version 3 thru 6 were previously added but this code was not updated to print the Swift version. rdar://35624067 llvm-svn: 324767
2018-01-23llvm-objdump: prevent out of bounds accesses during unwind dumping.Tim Northover1-57/+80
We were a bit too trusting about the offsets encoded in MachO compact unwind sections, so this passes every access through a bounds check just in case. It prevents a few segfaults on malformed object files, if one should ever come along. Mostly to silence fuzzers in the vague hope they might be able to produce something useful without the noise. llvm-svn: 323198
2017-12-15Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent1-4/+332
Summary: llvm-objdump's Mach-O parser was updated in r306037 to display external relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O parser to display local relocations for MH_PRELOAD files. When used with the -macho option relocations will be displayed in a historical format. All tests are passing for llvm, clang, and lld. llvm-objdump builds without compiler warnings. rdar://35778019 Reviewers: enderby Reviewed By: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41199 llvm-svn: 320832
2017-12-13reverting out -r320532 because a warning is breaking the lld buildMichael Trent1-332/+4
llvm-svn: 320534
2017-12-12Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent1-4/+332
Summary: llvm-objdump's Mach-O parser was updated in r306037 to display external relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O parser to display local relocations for MH_PRELOAD files. When used with the -macho option relocations will be displayed in a historical format. rdar://35778019 Reviewers: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41061 llvm-svn: 320532
2017-12-08Reverting r320166 to fix test failures.Michael Trent1-326/+4
llvm-svn: 320174
2017-12-08Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent1-4/+326
Summary: llvm-objdump's Mach-O parser was updated in r306037 to display external relocations for MH_KEXT_BUNDLE file types. This change extends the Macho-O parser to display local relocations for MH_PRELOAD files. When used with the -macho option relocations will be displayed in a historical format. rdar://35778019 Reviewers: enderby Reviewed By: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40867 llvm-svn: 320166
2017-12-05Test commit, as per the LLVM Developer Policy.Michael Trent1-0/+1
Commit message, as per the same policy. I added a blank space to the end of the file. Excelsior. llvm-svn: 319743
2017-10-18Untabify.NAKAMURA Takumi1-2/+2
llvm-svn: 316079
2017-10-09[llvm-objdump] Use initializer list for scoped xar api constructorsFrancis Ricci1-4/+3
llvm-svn: 315243
2017-10-06Guard xar RAII behind HAVE_LIBXARFrancis Ricci1-0/+2
llvm-svn: 315072