summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/MachODump.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [llvm-objdump] for mach-o add -bind, -lazy-bind, and -weak-bind optionsNick Kledzik2014-09-161-1/+116
| | | | | | | | | | | | | | | | This finishes the ability of llvm-objdump to print out all information from the LC_DYLD_INFO load command. The -bind option prints out symbolic references that dyld must resolve immediately. The -lazy-bind option prints out symbolc reference that are lazily resolved on first use. The -weak-bind option prints out information about symbols which dyld must try to coalesce across images. llvm-svn: 217853
* [llvm-objdump] Use PRIX64 with format()Nick Kledzik2014-09-131-1/+2
| | | | llvm-svn: 217724
* [llvm-objdump] support -rebase option for mach-o to dump rebasing infoNick Kledzik2014-09-121-0/+106
| | | | | | | | | | Similar to my previous -exports-trie option, the -rebase option dumps info from the LC_DYLD_INFO load command. The rebasing info is a list of the the locations that dyld needs to adjust if a mach-o image is not loaded at its preferred address. Since ASLR is now the default, images almost never load at their preferred address, and thus need to be rebased by dyld. llvm-svn: 217709
* llvm-objdump: don't crash when __compact_unwind has no relocs.Tim Northover2014-09-091-0/+3
| | | | llvm-svn: 217433
* Adds the next bit of support for llvm-objdump’s -private-headers for ↵Kevin Enderby2014-09-041-1/+303
| | | | | | | | | executable Mach-O files. This adds the printing of more load commands, so that the normal load commands in a typical X86 Mach-O executable can all be printed. llvm-svn: 217172
* Replace printf with outs() <<Nick Kledzik2014-09-031-1/+1
| | | | llvm-svn: 217005
* Nuke MCAnalysis.Sean Silva2014-09-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code is buggy and barely tested. It is also mostly boilerplate. (This includes MCObjectDisassembler, which is the interface to that functionality) Following an IRC discussion with Jim Grosbach, it seems sensible to just nuke the whole lot of functionality, and dig it up from VCS if necessary (I hope not!). All of this stuff appears to have been added in a huge patch dump (look at the timeframe surrounding e.g. r182628) where almost every patch seemed to be untested and not reviewed before being committed. Post-review responses to the patches were never addressed. I don't think any of it would have passed pre-commit review. I doubt anyone is depending on this, since this code appears to be extremely buggy. In limited testing that Michael Spencer and I did, we couldn't find a single real-world object file that wouldn't crash the CFG reconstruction stuff. The symbolizer stuff has O(n^2) behavior and so is not much use to anyone anyway. It seemed simpler to remove them as a whole. Most of this code is boilerplate, which is the only way it was able to scrape by 60% coverage. HEADSUP: Modules folks, some files I nuked were referenced from include/llvm/module.modulemap; I just deleted the references. Hopefully that is the right fix (one was a FIXME though!). llvm-svn: 216983
* Code review tweaksNick Kledzik2014-09-021-17/+17
| | | | llvm-svn: 216931
* Object/llvm-objdump: allow dumping of mach-o exports trieNick Kledzik2014-08-301-0/+60
| | | | | | | | | | | | | | | | | | MachOObjectFile in lib/Object currently has no support for parsing the rebase, binding, and export information from the LC_DYLD_INFO load command in final linked mach-o images. This patch adds support for parsing the exports trie data structure. It also adds an option to llvm-objdump to dump that export info. I did the exports parsing first because it is the hardest. The information is encoded in a trie structure, but the standard ObjectFile way to inspect content is through iterators. So I needed to make an iterator that would do a non-recursive walk through the trie and maintain the concatenation of edges needed for the current string prefix. I plan to add similar support in MachOObjectFile and llvm-objdump to parse/display the rebasing and binding info too. llvm-svn: 216808
* Next bit of support for llvm-objdump’s -private-headers for Mach-O files.Kevin Enderby2014-08-291-3/+495
| | | | | | | This adds the printing of the LC_SEGMENT load command and sections, LC_SYMTAB and LC_DYSYMTAB load commands. llvm-svn: 216795
* This code is from r216285, which did not go out to the mailing list for some ↵Aaron Ballman2014-08-241-6/+1
| | | | | | | | reason. The switch statement would never fire due to the preceding break statement. Also, the switch statement has a default label with no case labels. Simplified the code, and allow it to execute. llvm-svn: 216346
* Add the start of the support for llvm-objdump’s -private-headers for ↵Kevin Enderby2014-08-221-0/+294
| | | | | | | | Mach-O files. This adds the printing of the mach header. Load command printing will be next. llvm-svn: 216285
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
* Make llvm-objdump handle both arm and thumb disassembly from the same Mach-OKevin Enderby2014-08-181-10/+77
| | | | | | | | | | file with -macho, the Mach-O specific object file parser option. After some discussion I chose to do this implementation contained in the logic of llvm-objdump’s MachODump.cpp using a second disassembler for thumb when needed and with updates mostly contained in the MachOObjectFile class. llvm-svn: 215931
* Silencing some -Wcast-qual warnings and removing some C-style casts at the ↵Aaron Ballman2014-08-141-2/+3
| | | | | | same time. NFC. llvm-svn: 215643
* llvm-objdump: print contents of MachO __unwind_info sectionsTim Northover2014-08-121-11/+249
| | | | llvm-svn: 215437
* llvm-objdump: fix remaining use of %x format specifier for 64-bit valuesTim Northover2014-08-111-1/+1
| | | | | | Third time lucky. This should finally fix the ARM (& MIPS, I think) bots. llvm-svn: 215349
* llvm-objdump: add missing % in format specifier.Tim Northover2014-08-081-2/+2
| | | | llvm-svn: 215198
* llvm-objdump: use portable format specifiers for info.Tim Northover2014-08-081-6/+6
| | | | | | | | ARM bots (& others, I think, now that I look) were failing because we were using incorrect printf-style format specifiers. They were wrong on almost any platform, actually, just mostly harmlessly so. llvm-svn: 215196
* Add the -mcpu= option to llvm-objdump for use with the disassemblers.Kevin Enderby2014-08-061-1/+10
| | | | | | | Also make the disassembler created with the Mach-O parser (the -m option) pick up the Target specific attributes specified with -mattr option. llvm-svn: 215032
* llvm-objdump: implement printing for MachO __compact_unwind info.Tim Northover2014-08-011-0/+223
| | | | llvm-svn: 214509
* Use a reference instead of a pointer.Rafael Espindola2014-07-311-1/+1
| | | | | | This makes using a std::unique_ptr in the caller more convenient. llvm-svn: 214433
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-3/+3
| | | | llvm-svn: 214377
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-9/+10
| | | | llvm-svn: 212405
* Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola2014-06-231-2/+2
| | | | | | | | This makes the buffer ownership on error conditions very natural. The buffer is only moved out of the argument if an object is constructed that now owns the buffer. llvm-svn: 211546
* Remove 'using std::error_code' from tools.Rafael Espindola2014-06-131-3/+2
| | | | llvm-svn: 210876
* Remove all uses of 'using std::error_code' from headers.Rafael Espindola2014-06-131-0/+1
| | | | llvm-svn: 210866
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* [C++] Use 'nullptr'. Tools edition.Craig Topper2014-04-251-2/+2
| | | | llvm-svn: 207176
* [DWARF parser] Turn DILineInfo into a struct.Alexey Samsonov2014-04-181-3/+3
| | | | | | | | | | Immutable DILineInfo doesn't bring any benefits and complicates code. Also, use std::string instead of SmallString<16> for file and function names - their length can vary significantly. No functionality change. llvm-svn: 206654
* [MC] Require an MCContext when constructing an MCDisassembler.Lang Hames2014-04-151-1/+3
| | | | | | | | | | | | | | | | This patch re-introduces the MCContext member that was removed from MCDisassembler in r206063, and requires that an MCContext be passed in at MCDisassembler construction time. (Previously the MCContext member had been initialized in an ad-hoc fashion after construction). The MCCContext member can be used by MCDisassembler sub-classes to construct constant or target-specific MCExprs. This patch updates disassemblers for in-tree targets, and provides the MCRegisterInfo instance that some disassemblers were using through the MCContext (previously those backends were constructing their own MCRegisterInfo instances). llvm-svn: 206241
* [C++11] Introduce ObjectFile::symbols() to use range-based loops.Alexey Samsonov2014-03-171-11/+8
| | | | | | | | | | | | Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3081 llvm-svn: 204031
* [C++11] Introduce SectionRef::relocations() to use range-based loopsAlexey Samsonov2014-03-141-6/+4
| | | | | | | | | | | | Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3077 llvm-svn: 203927
* [C++11] Use ObjectFile::sections() in commandline llvm toolsAlexey Samsonov2014-03-131-7/+4
| | | | llvm-svn: 203802
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-16/+16
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles2014-03-051-2/+2
| | | | llvm-svn: 202957
* Change the begin and end methods in ObjectFile to match the style guide.Rafael Espindola2014-02-101-6/+6
| | | | llvm-svn: 201108
* Simplify the handling of iterators in ObjectFile.Rafael Espindola2014-01-301-7/+7
| | | | | | | | | | | | None of the object file formats reported error on iterator increment. In retrospect, that is not too surprising: no object format stores symbols or sections in a linked list or other structure that requires chasing pointers. As a consequence, all error checking can be done on begin() and end(). This reduces the text segment of bin/llvm-readobj in my machine from 521233 to 518526 bytes. llvm-svn: 200442
* Be a bit more consistent about using ErrorOr when constructing Binary objects.Rafael Espindola2014-01-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | The constructors of classes deriving from Binary normally take an error_code as an argument to the constructor. My original intent was to change them to have a trivial constructor and move the initial parsing logic to a static method returning an ErrorOr. I changed my mind because: * A constructor with an error_code out parameter is extremely convenient from the implementation side. We can incrementally construct the object and give up when we find an error. * It is very efficient when constructing on the stack or when there is no error. The only inefficient case is where heap allocating and an error is found (we have to free the memory). The result is that this is a much smaller patch. It just standardizes the create* helpers to return an ErrorOr. Almost no functionality change: The only difference is that this found that we were trying to read past the end of COFF import library but ignoring the error. llvm-svn: 199770
* Remove several unused variables.Rafael Espindola2013-10-011-2/+0
| | | | | | Patch by Alp Toker. llvm-svn: 191757
* Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis2013-09-011-15/+15
| | | | llvm-svn: 189728
* Revert "Fix the build broken by r189315." and "Move everything depending on ↵Charles Davis2013-08-271-16/+15
| | | | | | | | | Object/MachOFormat.h over to Support/MachO.h." This reverts commits r189319 and r189315. r189315 broke some tests on what I believe are big-endian platforms. llvm-svn: 189321
* Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis2013-08-271-15/+16
| | | | llvm-svn: 189315
* keep only the StringRef version of getFileOrSTDIN.Rafael Espindola2013-06-251-1/+1
| | | | llvm-svn: 184826
* Teach llvm-objdump with the -macho parser how to use the data in code tableKevin Enderby2013-06-061-6/+112
| | | | | | | | | | | | | | | from the LC_DATA_IN_CODE load command. And when disassembling print the data in code formatted for the kind of data it and not disassemble those bytes. I added the format specific functionality to the derived class MachOObjectFile since these tables only appears in Mach-O object files. This is my first attempt to modify the libObject stuff so if folks have better suggestions how to fit this in or suggestions on the implementation please let me know. rdar://11791371 llvm-svn: 183424
* Handle relocations that don't point to symbols.Rafael Espindola2013-06-051-3/+2
| | | | | | | | In ELF (as in MachO), not all relocations point to symbols. Represent this properly by using a symbol_iterator instead of a SymbolRef. Update llvm-readobj ELF's dumper to handle relocatios without symbols. llvm-svn: 183284
* MC: Disassembled CFG reconstruction.Ahmed Bougacha2013-05-241-291/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch builds on some existing code to do CFG reconstruction from a disassembled binary: - MCModule represents the binary, and has a list of MCAtoms. - MCAtom represents either disassembled instructions (MCTextAtom), or contiguous data (MCDataAtom), and covers a specific range of addresses. - MCBasicBlock and MCFunction form the reconstructed CFG. An MCBB is backed by an MCTextAtom, and has the usual successors/predecessors. - MCObjectDisassembler creates a module from an ObjectFile using a disassembler. It first builds an atom for each section. It can also construct the CFG, and this splits the text atoms into basic blocks. MCModule and MCAtom were only sketched out; MCFunction and MCBB were implemented under the experimental "-cfg" llvm-objdump -macho option. This cleans them up for further use; llvm-objdump -d -cfg now generates graphviz files for each function found in the binary. In the future, MCObjectDisassembler may be the right place to do "intelligent" disassembly: for example, handling constant islands is just a matter of splitting the atom, using information that may be available in the ObjectFile. Also, better initial atom formation than just using sections is possible using symbols (and things like Mach-O's function_starts load command). This brings two minor regressions in llvm-objdump -macho -cfg: - The printing of a relocation's referenced symbol. - An annotation on loop BBs, i.e., which are their own successor. Relocation printing is replaced by the MCSymbolizer; the basic CFG annotation will be superseded by more related functionality. llvm-svn: 182628
* Remove the MachineMove class.Rafael Espindola2013-05-131-2/+3
| | | | | | | | | | | | It was just a less powerful and more confusing version of MCCFIInstruction. A side effect is that, since MCCFIInstruction uses dwarf register numbers, calls to getDwarfRegNum are pushed out, which should allow further simplifications. I left the MachineModuleInfo::addFrameMove interface unchanged since this patch was already fairly big. llvm-svn: 181680
* Clarify getRelocationAddress x getRelocationOffset a bit.Rafael Espindola2013-04-251-1/+1
| | | | | | | | | | getRelocationAddress is for dynamic libraries and executables, getRelocationOffset for relocatable objects. Mark the getRelocationAddress of COFF and MachO as not implemented yet. Add a test of ELF's. llvm-readobj -r now prints the same values as readelf -r. llvm-svn: 180259
* Don't read one command past the end.Rafael Espindola2013-04-191-2/+6
| | | | | | | | | Thanks to Evgeniy Stepanov for reporting this. It might be a good idea to add a command iterator abstraction to MachO.h, but this fixes the bug for now. llvm-svn: 179848
OpenPOWER on IntegriCloud