aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump
AgeCommit message (Collapse)AuthorFilesLines
2014-09-10Object: Add support for bigobjDavid Majnemer2-28/+17
This adds support for reading the "bigobj" variant of COFF produced by cl's /bigobj and mingw's -mbig-obj. The most significant difference that bigobj brings is more than 2**16 sections to COFF. bigobj brings a few interesting differences with it: - It doesn't have a Characteristics field in the file header. - It doesn't have a SizeOfOptionalHeader field in the file header (it's only used in executable files). - Auxiliary symbol records have the same width as a symbol table entry. Since symbol table entries are bigger, so are auxiliary symbol records. Write support will come soon. Differential Revision: http://reviews.llvm.org/D5259 llvm-svn: 217496
2014-09-09llvm-objdump: don't crash when __compact_unwind has no relocs.Tim Northover1-0/+3
llvm-svn: 217433
2014-09-04Adds the next bit of support for llvm-objdump’s -private-headers for ↵Kevin Enderby1-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
2014-09-03Replace printf with outs() <<Nick Kledzik1-1/+1
llvm-svn: 217005
2014-09-02Nuke MCAnalysis.Sean Silva5-124/+2
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
2014-09-02Code review tweaksNick Kledzik1-17/+17
llvm-svn: 216931
2014-08-30Object/llvm-objdump: allow dumping of mach-o exports trieNick Kledzik3-2/+79
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
2014-08-29Next bit of support for llvm-objdump’s -private-headers for Mach-O files.Kevin Enderby1-3/+495
This adds the printing of the LC_SEGMENT load command and sections, LC_SYMTAB and LC_DYSYMTAB load commands. llvm-svn: 216795
2014-08-25Modernize raw_fd_ostream's constructor a bit.Rafael Espindola1-8/+8
Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
2014-08-24This code is from r216285, which did not go out to the mailing list for some ↵Aaron Ballman1-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
2014-08-22Add the start of the support for llvm-objdump’s -private-headers for ↵Kevin Enderby3-0/+297
Mach-O files. This adds the printing of the mach header. Load command printing will be next. llvm-svn: 216285
2014-08-19Don't own the buffer in object::Binary.Rafael Espindola2-9/+13
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
2014-08-18Make llvm-objdump handle both arm and thumb disassembly from the same Mach-OKevin Enderby1-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
2014-08-17llvm-objdump: don't print relocations in non-relocatable files.Rafael Espindola1-0/+5
This matches the behavior of GNU objdump. llvm-svn: 215844
2014-08-17Fix an off-by-one bug in the target independent llvm-objdump.Rafael Espindola1-10/+5
It would prevent the display of a single byte instruction before a label. Patch by Steve King! llvm-svn: 215837
2014-08-14Silencing some -Wcast-qual warnings and removing some C-style casts at the ↵Aaron Ballman1-2/+3
same time. NFC. llvm-svn: 215643
2014-08-13Canonicalize header guards into a common format.Benjamin Kramer1-2/+2
Add header guards to files that were missing guards. Remove #endif comments as they don't seem common in LLVM (we can easily add them back if we decide they're useful) Changes made by clang-tidy with minor tweaks. llvm-svn: 215558
2014-08-12llvm-objdump: print contents of MachO __unwind_info sectionsTim Northover1-11/+249
llvm-svn: 215437
2014-08-11llvm-objdump: fix remaining use of %x format specifier for 64-bit valuesTim Northover1-1/+1
Third time lucky. This should finally fix the ARM (& MIPS, I think) bots. llvm-svn: 215349
2014-08-08llvm-objdump: add missing % in format specifier.Tim Northover1-2/+2
llvm-svn: 215198
2014-08-08llvm-objdump: use portable format specifiers for info.Tim Northover1-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
2014-08-06Add the -mcpu= option to llvm-objdump for use with the disassemblers.Kevin Enderby3-4/+21
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
2014-08-01Remove some calls to std::move.Rafael Espindola1-3/+3
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get a reference to it. Thanks to David Blaikie for the suggestion. llvm-svn: 214516
2014-08-01llvm-objdump: implement printing for MachO __compact_unwind info.Tim Northover3-2/+230
llvm-svn: 214509
2014-07-31Use a reference instead of a pointer.Rafael Espindola1-1/+1
This makes using a std::unique_ptr in the caller more convenient. llvm-svn: 214433
2014-07-31Move MCObjectSymbolizer.h to MC/MCAnalysis.Rafael Espindola1-1/+1
The cpp file is already in lib/MC/MCAnalysis. llvm-svn: 214424
2014-07-31Use std::unique_ptr to make the ownership explicit.Rafael Espindola2-5/+5
llvm-svn: 214377
2014-07-24Update library dependencies.NAKAMURA Takumi1-0/+1
llvm-svn: 213832
2014-07-14llvm-objdump: Handle BSS sections larger than the object fileDavid Majnemer1-4/+8
The size of the uninitialized sections, like BSS, can exceed the size of the object file. Do not attempt to grab the contents of such sections. llvm-svn: 212953
2014-07-06Update the MemoryBuffer API to use ErrorOr.Rafael Espindola1-9/+10
llvm-svn: 212405
2014-07-02Fix configure+make build.Rafael Espindola1-1/+1
llvm-svn: 212210
2014-07-02Move CFG building code to a new lib/MC/MCAnalysis library.Rafael Espindola3-5/+6
The new library is 150KB on a Release+Asserts build, so it is quiet a bit of code that regular users of MC don't need to link with now. llvm-svn: 212209
2014-06-26Revert "Introduce a string_ostream string builder facilty"Alp Toker1-4/+8
Temporarily back out commits r211749, r211752 and r211754. llvm-svn: 211814
2014-06-26Introduce a string_ostream string builder faciltyAlp Toker1-8/+4
string_ostream is a safe and efficient string builder that combines opaque stack storage with a built-in ostream interface. small_string_ostream<bytes> additionally permits an explicit stack storage size other than the default 128 bytes to be provided. Beyond that, storage is transferred to the heap. This convenient class can be used in most places an std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair would previously have been used, in order to guarantee consistent access without byte truncation. The patch also converts much of LLVM to use the new facility. These changes include several probable bug fixes for truncated output, a programming error that's no longer possible with the new interface. llvm-svn: 211749
2014-06-23Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola1-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
2014-06-16Convert the Archive API to use ErrorOr.Rafael Espindola1-3/+3
Now that we have c++11, even things like ErrorOr<std::unique_ptr<...>> are easy to use. No intended functionality change. llvm-svn: 211033
2014-06-13Remove 'using std::error_code' from tools.Rafael Espindola3-31/+27
llvm-svn: 210876
2014-06-13Remove all uses of 'using std::error_code' from headers.Rafael Espindola3-3/+3
llvm-svn: 210866
2014-06-12Don't use 'using std::error_code' in include/llvm.Rafael Espindola2-0/+2
This should make sure that most new uses use the std prefix. llvm-svn: 210835
2014-06-12Remove system_error.h.Rafael Espindola3-3/+3
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
2014-06-11Use std::error_code instead of llvm::error_code.Rafael Espindola1-1/+0
The idea of this patch is to turn llvm/Support/system_error.h into a transitional header that just brings in the erorr_code api to the llvm namespace. I will remove it shortly afterwards. The cases where the general idea needed some tweaking: * std::errc is a namespace in msvc, so we cannot use "using std::errc". I could add an #ifdef, but there were not that many uses, so I just added std:: to them in this patch. * Template specialization had to be moved to the std namespace in this patch set already. * The msvc implementation of default_error_condition doesn't seem to provide the same transformations as we need. Not too surprising since the standard doesn't actually say what "equivalent" means. I fixed the problem by keeping our old mapping and using it at error_code construction time. Despite these shortcomings I think this is still a good thing. Some reasons: * The different implementations of system_error might improve over time. * It removes 925 lines of code from llvm already. * It removes 6313 bytes from the text segment of the clang binary when it is built with gcc and 2816 bytes when building with clang and libstdc++. llvm-svn: 210687
2014-04-25[C++] Use 'nullptr'. Tools edition.Craig Topper2-4/+4
llvm-svn: 207176
2014-04-18[DWARF parser] Turn DILineInfo into a struct.Alexey Samsonov1-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
2014-04-17objdump: identify WoA WinCOFF/ARM correctlySaleem Abdulrasool1-0/+6
Since LLVM currently only supports WinCOFF, assume that the input is WinCOFF rather than another type of COFF file (ECOFF/XCOFF). If the architecture is detected as thumb (e.g. the file has a IMAGE_FILE_MACHINE_ARMNT magic) then use a triple of thumbv7-windows. This allows for objdump to properly handle WoA object files without having to specify the target triple manually. llvm-svn: 206446
2014-04-15[MC] Require an MCContext when constructing an MCDisassembler.Lang Hames2-9/+12
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
2014-04-14tools: fix heap-buffer-overrun detected via ASANSaleem Abdulrasool1-0/+3
Once the auxiliary fields relating to the filename have been inspected, any following auxiliary fields need not be visited as they have been consumed (the following fields comprise the filepath as a single unit). Adjust the test to catch this even if ASAN is not enabled. llvm-svn: 206190
2014-04-14tools: simplify symbol handling in objdumpSaleem Abdulrasool1-25/+28
Rather than switching behaviour on whether a previous symbol has an auxiliary symbol record for the next count of elements, simply iterate over the auxiliary symbols right after processing the current symbol entry. This makes the behaviour much simpler to follow and similar to llvm-readobj and yaml2obj. llvm-svn: 206146
2014-04-14tools: address possible non-null terminated filenamesSaleem Abdulrasool1-15/+7
If a filename is a multiple of 18 characters, there will be no null-terminator. This will result in an invalid access by the constructed StringRef. Add a test case to exercise this and fix that handling. Address this same vulnerability in llvm-readobj as well. llvm-svn: 206145
2014-04-13tools: avoid a string duplicationSaleem Abdulrasool1-8/+4
The auxiliary file records are contiguous and only contain the filename. Construct a StringRef directly rather than copying to a temporary buffer. Suggested by majnemer on IRC! llvm-svn: 206139
2014-04-13tools: teach objdump about FILE aux recordsSaleem Abdulrasool1-4/+26
Add support for file auxiliary symbol entries in COFF symbol tables. A COFF symbol table with a FILE entry is followed by sizeof(__FILE__) / 18 auxiliary symbol records which contain the filename. Read them and form the original filename that the record contains. Then display the name in the output. llvm-svn: 206126