summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/MachODump.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Reapply: "objdump: Support newer ObjC image info flags"Dave Lee2018-07-061-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
* Revert "objdump: Support newer ObjC image info flags"Dave Lee2018-07-061-6/+0
| | | | | | This reverts commit 8c4cc472e7a67bd3b2b20cc4cf32d31af29bc7e9. llvm-svn: 336402
* objdump: Support newer ObjC image info flagsDave Lee2018-07-051-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
* [llvm-objdump] Add --archive-headers (-a) optionPaul Semel2018-07-051-5/+0
| | | | llvm-svn: 336357
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-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
* [llvm-objdump] Issue error message when object file cannot be createdGerolf Hoflehner2018-04-191-4/+6
| | | | llvm-svn: 330364
* [tools] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-011-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
* For llvm-objdump and Mach-O files, fix the printing of module init andKevin Enderby2018-03-201-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
* For llvm-objdump and Mach-O files, update the printing of some thread statesKevin Enderby2018-03-081-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
* [llvm-objdump] Use unique_ptr to simplify memory ownershipDavid Blaikie2018-02-201-34/+31
| | | | | | Followup to r325099/r325100 to simplify further. llvm-svn: 325612
* Use delete[] instead of freeSerge Pavlov2018-02-141-2/+2
| | | | llvm-svn: 325100
* Use delete[] to deallocate array of charsSerge Pavlov2018-02-141-2/+2
| | | | llvm-svn: 325099
* Refactor DisassembleInfo in MachODump.cppSerge Pavlov2018-02-141-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
* llvm-objdump when printing the Objective-C meta data also prints the Swift ABIKevin Enderby2018-02-091-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
* llvm-objdump: prevent out of bounds accesses during unwind dumping.Tim Northover2018-01-231-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
* Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent2017-12-151-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
* reverting out -r320532 because a warning is breaking the lld buildMichael Trent2017-12-131-332/+4
| | | | llvm-svn: 320534
* Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent2017-12-121-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
* Reverting r320166 to fix test failures.Michael Trent2017-12-081-326/+4
| | | | llvm-svn: 320174
* Updated llvm-objdump to display local relocations in Mach-O binariesMichael Trent2017-12-081-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
* Test commit, as per the LLVM Developer Policy.Michael Trent2017-12-051-0/+1
| | | | | | | Commit message, as per the same policy. I added a blank space to the end of the file. Excelsior. llvm-svn: 319743
* Untabify.NAKAMURA Takumi2017-10-181-2/+2
| | | | llvm-svn: 316079
* [llvm-objdump] Use initializer list for scoped xar api constructorsFrancis Ricci2017-10-091-4/+3
| | | | llvm-svn: 315243
* Guard xar RAII behind HAVE_LIBXARFrancis Ricci2017-10-061-0/+2
| | | | llvm-svn: 315072
* [llvm-objdump] Add RAII for xar apisFrancis Ricci2017-10-061-15/+33
| | | | | | | | | | | | | | | Summary: xar_open and xar_iter_new require manual calls to close/free functions to deallocate resources. This makes it easy to introduce memory leaks, so add RAII struct wrappers for these resources. Reviewers: enderby, rafael, compnerd, lhames, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38598 llvm-svn: 315069
* [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
* Fix a bug in llvm-objdump when disassembling using the wrong default CPUKevin Enderby2017-09-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | in the second slice of a Mach-O universal file. The code in llvm-objdump in in DisassembleMachO() was getting the default CPU then incorrectly setting into the global variable used for the -mcpu option if that was not set. This caused a second call to DisassembleMachO() to use the wrong default CPU when disassembling the next slice in a Mach-O universal file. And would result in bad disassembly and an error message about an recognized processor for the target: % llvm-objdump -d -m -arch all fat.macho-armv7s-arm64 fat.macho-armv7s-arm64 (architecture armv7s): (__TEXT,__text) section armv7: 0: 60 47 bx r12 fat.macho-armv7s-arm64 (architecture arm64): 'cortex-a7' is not a recognized processor for this target (ignoring processor) 'cortex-a7' is not a recognized processor for this target (ignoring processor) (__TEXT,__text) section ___multc3: 0: .long 0x1e620810 rdar://34439149 llvm-svn: 313921
* [dwarfdump] Make .eh_frame an alias for .debug_frameJonas Devlieghere2017-09-181-3/+2
| | | | | | | | | | | | | | | | | | | | This patch makes the `.eh_frame` extension an alias for `.debug_frame`. Up till now it was only possible to dump the section using objdump, but not with dwarfdump. Since the two are essentially interchangeable, we dump whichever of the two is present. As a workaround, this patch also adds parsing for 3 currently unimplemented CFA instructions: `DW_CFA_def_cfa_expression`, `DW_CFA_expression`, and `DW_CFA_val_expression`. Because I lack the required knowledge, I just parse the fields without actually creating the instructions. Finally, this also fixes the typo in the `.debug_frame` section name which incorrectly contained a trailing `s`. Differential revision: https://reviews.llvm.org/D37852 llvm-svn: 313530
* [llvm-objdump] Fix memory leaks in macho dumpFrancis Ricci2017-09-131-2/+5
| | | | | | | | | | | | Summary: Detected by LeakSanitizer for Darwin Reviewers: enderby, rafael Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37750 llvm-svn: 313146
* Untabify.NAKAMURA Takumi2017-08-281-31/+31
| | | | llvm-svn: 311875
* [llvm] Update MachOObjectFile::exports interfaceAlexander Shaposhnikov2017-07-291-1/+1
| | | | | | | | | | This diff removes the second argument of the method MachOObjectFile::exports. In all in-tree uses this argument is equal to "this" and without this argument the interface seems to be cleaner. Test plan: make check-all llvm-svn: 309462
* Add error handling to the dyld compact export entries in libObject.Kevin Enderby2017-07-201-1/+4
| | | | | | | | | | | | | | | | | | | | | lld needs a matching change for this will be my next commit. Expect it to fail build until that matching commit is picked up by the bots. Like the changes in r296527 for dyld bind entires and the changes in r298883 for lazy bind, weak bind and rebase entries the export entries are the last of the dyld compact info to have error handling added. This follows the model of iterators that can fail that Lang Hanes designed when fixing the problem for bad archives r275316 (or r275361). So that iterating through the exports now terminates if there is an error and returns an llvm::Error with an error message in all cases for malformed input. This change provides the plumbing for the error handling, all the needed testing of error conditions and test cases for all of the unique error messages. llvm-svn: 308690
* Use delegation instead of inheritance.Rafael Espindola2017-07-191-2/+2
| | | | | | | | | | This changes DwarfContext to delegate to DwarfObject instead of having pure virtual methods. With this DwarfContextInMemory is replaced with an implementation of DwarfObject that is local to a .cpp file. llvm-svn: 308543
* Updated llvm-objdump for arm64 Mach-O MH_KEXT_BUNDLE file types soKevin Enderby2017-06-221-2/+7
| | | | | | | | | it symbolically disassembles the __text section from the __TEXT_EXEC segment not the usual __TEXT segment by default. rdar://30590208 llvm-svn: 306046
* Updated llvm-objdump symbolic disassembly with x86_64 Mach-O MH_KEXT_BUNDLEKevin Enderby2017-06-221-4/+38
| | | | | | | | | file types so it symbolically disassembles operands using the external relocation entries. rdar://31521343 llvm-svn: 306037
* Updated llvm-objdump with Mach-O files and the -objc-meta-data option soKevin Enderby2017-06-201-0/+6
| | | | | | | | that it symbolically prints the superclass when it has dyld bind info for it. rdar://7638823 llvm-svn: 305866
* Change llvm-objdump with Mach-O files and the -info-plist option with theKevin Enderby2017-06-201-1/+2
| | | | | | | | -no-leading-headers option so that it does not print the leading header. rdar://27378808 llvm-svn: 305849
* Fix a FIXME in llvm-objdump for the -exports-trie option that was not addingKevin Enderby2017-06-191-1/+17
| | | | | | | | | | in the base address. Without this Mach-O files, like 64-bit executables, don’t have the correct addresses printed for their exports. As the default is to link at address 0x100000000 not zero. llvm-svn: 305744
* Change llvm-nm for Mach-O files to use dyld info in some cases when printing ↵Kevin Enderby2017-06-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | symbols. In order to reduce swift binary sizes, Apple is now stripping swift symbols from the nlist symbol table. llvm-nm currently only looks at the nlist symbol table and misses symbols that are present in dyld info. This makes it hard to know the set of symbols for a binary using just llvm-nm. Unless you know to run llvm-objdump -exports-trie that can output the exported symbols in the dyld info from the export trie, which does so but in a different format. Also moving forward the time may come a when a fully linked Mach-O file that uses dyld will no longer have an nlist symbol table to avoid duplicating the symbol information. This change adds three flags to llvm-nm, -add-dyldinfo, -no-dyldinfo, and -dyldinfo-only. The first, -add-dyldinfo, has the same effect as when the new bit in the Mach-O header, MH_NLIST_OUTOFSYNC_WITH_DYLDINFO, appears in a binary. In that it looks through the dyld info from the export trie and adds symbols to be printed that are not already in its internal SymbolList variable. The -no-dyldinfo option turns this behavior off. The -dyldinfo-only option only looks at the dyld information and recreates the symbol table from the dyld info from the export trie and binding information. As if it the Mach-O file had no nlist symbol table. Also fixed a few bugs with Mach-O N_INDR symbols not correctly printing the indirect name, or in the same format as the old nm-classic program. rdar://32021551 llvm-svn: 305733
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-3/+4
| | | | | | | | | | | | 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
* [DWARF] Introduce Dump OptionsAdrian Prantl2017-06-011-1/+4
| | | | | | | | | | | This commit introduces a structure that holds all the flags that control the pretty printing of dwarf output. Patch by Spyridoula Gravani! Differential Revision: https://reviews.llvm.org/D33749 llvm-svn: 304446
* Add the rest of the error checking for Mach-O dyld compact bind entry errorsKevin Enderby2017-03-201-139/+21
| | | | | | | | | | | | | | | | | | | | | | | | | and test cases for each of the error checks. To do this more plumbing was needed so that the segment indexes and segment offsets can be checked. Basically what was done was the SegInfo from llvm-objdump’s MachODump.cpp was moved into libObject for Mach-O objects as BindRebaseSegInfo and it is only created when an iterator for bind or rebase entries are created. This commit really only adds the error checking and test cases for the bind table entires and the checking for the lazy bind and weak bind entries are still to be fully done as well as the rebase entires. Though some of the plumbing for those are added with this commit. Those other error checks and test cases will be added in follow on commits. Note, the two llvm_unreachable() calls should now actually be unreachable with the error checks in place and would take a logic bug in the error checking code to be reached if the segment indexes and segment offsets are used from a checked bind entry. Comments have been added to the methods that require the arguments to have been checked prior to calling. llvm-svn: 298292
* Actually add error handling to unpacking the dyld compact bind andKevin Enderby2017-02-281-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | other tables. Providing a helpful error message to what the error is and where the error occurred based on which opcode it was associated with. There have been handful of bug fixes dealing with bad bind info in object files, r294021 and r249845, which only put a band aid on the problem after a bad bind table was created after unpacking from its compact info. In these cases a bind table should have never been created and an error should have simply been generated. This change puts in place the plumbing to allow checking and returning of an error when the compact info is unpacked. This follows the model of iterators that can fail that Lang Hanes designed when fixing the problem for bad archives r275316 (or r275361). This change uses one of the existing test cases that now causes an error instead of printing <<bad library ordinal>> after a bad bind table is created. The error uses the offset into the opcode table as shown with the macOS dyldinfo(1) tool to indicate where the error is and which opcode and which parameter is in error. For example the exiting test case has this lazy binding opcode table: % dyldinfo -opcodes test/tools/llvm-objdump/Inputs/bad-ordinal.macho-x86_64 … lazy binding opcodes: 0x0000 BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x02, 0x00000010) 0x0002 BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(2) In the test case the binary only has one library so setting the library ordinal to the value of 2 in the BIND_OPCODE_SET_DYLIB_ORDINAL_IMM opcode at 0x0002 above is an error. This now produces this error message: % llvm-objdump -lazy-bind bad-ordinal.macho-x86_64 … llvm-objdump: 'bad-ordinal.macho-x86_64': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB bad library ordinal: 2 (max 1) for opcode at: 0x2) This change provides the plumbing for the error handling and one example of an error message. Other error checks and test cases will be added in follow on commits. llvm-svn: 296527
* Tweak the implementation of llvm-objdump’s -objc-meta-data option soKevin Enderby2017-02-091-63/+91
| | | | | | | | | that it works when the ObjC metadata sections end up in the __DATA_CONST or __DATA_DIRTY segments. rdar://26315238 llvm-svn: 294599
* llvm-objdump: make NoLeadingAddr work on more than just MachOSaleem Abdulrasool2017-02-081-3/+0
| | | | | | | | | Support printing the disassembly without the address on all formats rather than making it MachO specific. Patch by Jeff Muizelaar! llvm-svn: 294495
* Fix a bug in llvm-obdump(1) with the -macho and -info-plist optionsKevin Enderby2017-02-061-1/+1
| | | | | | | | | which caused it to print more than the (__TEXT,__info_plist) if that section did not end with a null. rdar://27378808 llvm-svn: 294236
* Fix a bug in llvm-obdump(1) with the -macho and -disassemble optionsKevin Enderby2017-02-061-1/+28
| | | | | | | | | | which caused it to not disassemble the bytes a the start of the section if the section had symbols and the first symbol was not at the start of the section. rdar://30143243 llvm-svn: 294212
* Fix a bug in llvm-obdump(1) with the -objc-meta-data flag with -machoKevin Enderby2017-02-031-1/+1
| | | | | | | | which caused a hang on a malformed binary with bad bind info. rdar://29672108 llvm-svn: 294021
* Fix a bug in llvm-obdump(1) with the -macho flag disassembling an objectKevin Enderby2017-01-311-2/+5
| | | | | | | | | | | | | without symbols that makes calls through a symbol stub which were not correctly being annotated with “## symbol stub for: _foo”. Just adds the same parameters for getting the annotations from DisAsm->getInstruction() and passing them to IP->printInst() from the code above when boolean variable symbolTableWorked was true. rdar://29791952 llvm-svn: 293662
* Change the llvm-obdump(1) behavior with the -macho flag and inappropriate ↵Kevin Enderby2017-01-301-2/+7
| | | | | | | | | | | | | | | | | | file types. To better match the old darwin otool(1) behavior, when llvm-obdump(1) is used with the -macho option and the input file is not an object file simply print the file name and this message: foo: is not an object file and continue on to process other input files. Also in this case don’t exit non-zero. This should help in some OSS projects' with autoconf scripts that are expecting the old darwin otool(1) behavior. rdar://26828015 llvm-svn: 293547
OpenPOWER on IntegriCloud