summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add printing the LC_ENCRYPTION_INFO_64 load command with llvm-objdump’s ↵Kevin Enderby2014-12-171-0/+5
| | | | | | | | -private-headers and add tests for the two AArch64 binaries. llvm-svn: 224400
* Add printing the LC_ENCRYPTION_INFO load command with llvm-objdump’s ↵Kevin Enderby2014-12-161-0/+5
| | | | | | -private-headers. llvm-svn: 224390
* Move three methods only used by MCJIT to MCJIT.Rafael Espindola2014-12-101-21/+6
| | | | | | | | These methods are only used by MCJIT and are very specific to it. In fact, they are also fairly specific to the fact that we have a dynamic linker of relocatable objects. llvm-svn: 223964
* Add mach-o LC_RPATH support to llvm-objdumpJean-Daniel Dupas2014-12-041-0/+5
| | | | | | | | | | Summary: Add rpath load command support in Mach-O object and update llvm-objdump to use it. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6512 llvm-svn: 223343
* Object, Mach-O: Refactor and clean code upDavid Majnemer2014-11-131-12/+25
| | | | | | | Don't assert if we can return an error code, reuse existing functionality like is64Bit(). llvm-svn: 221915
* Remove the static version of getScatteredRelocationType() now that r221211 addedKevin Enderby2014-11-041-5/+0
| | | | | | | | a public version MachOObjectFile::getScatteredRelocationType(). This should fix the build bot for the unused function error. llvm-svn: 221216
* Add the code and test cases for 32-bit Intel to llvm-objdump’s Mach-O ↵Kevin Enderby2014-11-041-0/+5
| | | | | | symbolizer. llvm-svn: 221211
* Fix unicode chars into ascii in comment lines.NAKAMURA Takumi2014-10-271-1/+1
| | | | llvm-svn: 220668
* [Object] Fix MachO's getUuid to return a pointer into the object instead of ↵Benjamin Kramer2014-10-241-2/+3
| | | | | | | | | a dangling ArrayRef. This works because uuid's are always little endian so it's not swapped. Fixes use-after-return reported by asan. llvm-svn: 220567
* Update llvm-objdump’s Mach-O symbolizer code for Objective-C references.Kevin Enderby2014-10-231-2/+38
| | | | | | | This prints disassembly comments for Objective-C references to CFStrings, Selectors, Classes and method calls. llvm-svn: 220500
* [MCJIT] Temporarily revert r220245 - it broke several bots.Lang Hames2014-10-211-3/+0
| | | | | | (See e.g. http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/17653) llvm-svn: 220249
* [MCJIT] Make MCJIT honor symbol visibility settings when populating the globalLang Hames2014-10-201-0/+3
| | | | | | | | symbol table. Patch by Anthony Pesch. Thanks Anthony! llvm-svn: 220245
* [llvm-objdump] Fix mach-o binding decompression errorNick Kledzik2014-10-181-3/+3
| | | | llvm-svn: 220119
* Add MachOObjectFile::getUuid()Alexander Potapenko2014-10-151-1/+10
| | | | | | | This CL introduces MachOObjectFile::getUuid(). This function returns an ArrayRef to the object file's UUID, or an empty ArrayRef if the object file doesn't contain an LC_UUID load command. The new function is gonna be used by llvm-symbolizer. llvm-svn: 219866
* Remove bogus std::error_code returns form SectionRef.Rafael Espindola2014-10-081-81/+41
| | | | | | | | | | | | | | There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. llvm-svn: 219314
* [Object] keep trailing '\0' out of StringRef when parsing mach-o bindingsNick Kledzik2014-09-171-1/+1
| | | | llvm-svn: 217935
* [llvm-objdump] properly use c_str() with format("%s"). Improve ↵Nick Kledzik2014-09-171-10/+5
| | | | | | getLibraryShortNameByIndex() error handling. llvm-svn: 217930
* [llvm-objdump] for mach-o add -bind, -lazy-bind, and -weak-bind optionsNick Kledzik2014-09-161-1/+281
| | | | | | | | | | | | | | | | 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] support -rebase option for mach-o to dump rebasing infoNick Kledzik2014-09-121-0/+172
| | | | | | | | | | 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
* Adds the next bit of support for llvm-objdump’s -private-headers for ↵Kevin Enderby2014-09-041-0/+25
| | | | | | | | | 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
* Code review tweaksNick Kledzik2014-09-021-9/+9
| | | | llvm-svn: 216931
* Fix typo and formattingNick Kledzik2014-08-301-3/+3
| | | | llvm-svn: 216809
* Object/llvm-objdump: allow dumping of mach-o exports trieNick Kledzik2014-08-301-2/+241
| | | | | | | | | | | | | | | | | | 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
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-2/+2
| | | | | | just letting them be implicitly created. llvm-svn: 216525
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+84
| | | | | | | | | | 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
* llvm-objdump: don't print relocations in non-relocatable files.Rafael Espindola2014-08-171-0/+4
| | | | | | This matches the behavior of GNU objdump. llvm-svn: 215844
* Delete dead code. NFC.Rafael Espindola2014-08-081-20/+0
| | | | llvm-svn: 215224
* getLoadName is only implemented for ELF, make it ELF only.Rafael Espindola2014-08-081-5/+0
| | | | llvm-svn: 215219
* Use a simpler predicate. NFC.Rafael Espindola2014-08-081-31/+19
| | | | llvm-svn: 215218
* pr20589: Fix duplicated arch flag.Rafael Espindola2014-08-081-1/+1
| | | | llvm-svn: 215216
* Add two missing ARM cpusubtypes to the switch statement in Kevin Enderby2014-08-071-0/+4
| | | | | | | | | MachOObjectFile::getArch(uint32_t CPUType, uint32_t CPUSubType) . Upcoming changes will cause existing test cases to use this but I wanted to check in this obvious change separately. llvm-svn: 215150
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-2/+2
| | | | llvm-svn: 214377
* AArch64: remove arm64 triple enumerator.Tim Northover2014-07-231-2/+1
| | | | | | | | | | | | Having both Triple::arm64 and Triple::aarch64 is extremely confusing, and invites bugs where only one is checked. In reality, the only legitimate difference between the two (arm64 usually means iOS) is also present in the OS part of the triple and that's what should be checked. We still parse the "arm64" triple, just canonicalise it to Triple::aarch64, so there aren't any LLVM-side test changes. llvm-svn: 213743
* Namespace cleanup (no functional change)Artyom Skrobov2014-07-201-11/+7
| | | | llvm-svn: 213478
* extracting swapStruct into include/llvm/Support/MachO.h (no functional change)Artyom Skrobov2014-07-181-208/+9
| | | | llvm-svn: 213361
* [RuntimeDyld] Revert r211652 - MachO object GDB registration support.Lang Hames2014-07-151-5/+1
| | | | | | | | The registration scheme used in r211652 violated the read-only contract of MemoryBuffer. This caused crashes in llvm-rtdyld where macho objects were backed by read-only mmap'd memory. llvm-svn: 213086
* llvm-readobj: fix MachO relocatoin printing a bit.Tim Northover2014-07-041-0/+3
| | | | | | | | | | | | | | | | There were two issues here: 1. At the very least, scattered relocations cannot use the same code to determine the corresponding symbol being referred to. For some reason we pretend there is no symbol, even when one actually exists in the symtab, so to match this behaviour getRelocationSymbol should simply return symbols_end for scattered relocations. 2. Printing "-" when we can't get a symbol (including the scattered case, but not exclusively), isn't that helpful. In both cases there *is* interesting information in that field, so we should print it. As hex will do. Small part of rdar://problem/17553104 llvm-svn: 212332
* Speculatively fix some code handling Power64 MachO filesReid Kleckner2014-06-301-1/+1
| | | | | | | MSVC was warning on a switch containing only default labels. In this instance, it looks like it uncovered a real bug. :) llvm-svn: 212062
* Add the -arch flag support to llvm-nm to select the slice out of a Mach-OKevin Enderby2014-06-301-0/+102
| | | | | | | | universal file. This also includes support for -arch all, selecting the host architecture by default from a universal file and checking if -arch is used with a standard Mach-O it matches that architecture. llvm-svn: 212054
* macho-dump: add code to print LC_ID_DYLIB load commands.Tim Northover2014-06-301-0/+6
| | | | | | I want to check them in lld. llvm-svn: 212043
* Revert "Introduce a string_ostream string builder facilty"Alp Toker2014-06-261-3/+4
| | | | | | Temporarily back out commits r211749, r211752 and r211754. llvm-svn: 211814
* Introduce a string_ostream string builder faciltyAlp Toker2014-06-261-4/+3
| | | | | | | | | | | | | | | | | | | | 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
* [RuntimeDyld] Adds the necessary hooks to MCJIT to be able to debug generatedLang Hames2014-06-251-1/+5
| | | | | | | | MachO files using the GDB JIT debugging interface. Patch by Keno Fischer. Thanks Keno! llvm-svn: 211652
* Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.Rafael Espindola2014-06-241-7/+8
| | | | | | | Once the objects are constructed, they own the buffer. Passing a unique_ptr makes that clear. llvm-svn: 211595
* Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola2014-06-231-8/+7
| | | | | | | | 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
* Make ObjectFile and BitcodeReader always own the MemoryBuffer.Rafael Espindola2014-06-231-9/+7
| | | | | | | | | | This allows us to just use a std::unique_ptr to store the pointer to the buffer. The flip side is that they have to support releasing the buffer back to the caller. Overall this looks like a more efficient and less brittle api. llvm-svn: 211542
* Fix a warning about the use of const being ignored with a cast.Kevin Enderby2014-06-201-1/+1
| | | | llvm-svn: 211383
* Replacing the private implementations of SwapValue with calls to ↵Artyom Skrobov2014-06-141-118/+113
| | | | | | sys::swapByteOrder() llvm-svn: 210980
* Renaming SwapByteOrder() to getSwappedBytes()Artyom Skrobov2014-06-141-1/+1
| | | | | | The next commit will add swapByteOrder(), acting in-place llvm-svn: 210973
OpenPOWER on IntegriCloud