aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-06-05Add "-format darwin" to llvm-nm to be like darwin's nm(1) -m output.Kevin Enderby1-0/+223
This is a first step in seeing if it is possible to make llvm-nm produce the same output as darwin's nm(1). Darwin's default format is bsd but its -m output prints the longer Mach-O specific details. For now I added the "-format darwin" to do this (whos name may need to change in the future). As there are other Mach-O specific flags to nm(1) which I'm hoping to add some how in the future. But I wanted to see if I could get the correct output for -m flag using llvm-nm and the libObject interfaces. I got this working but would love to hear what others think about this approach to getting object/format specific details printed with llvm-nm. llvm-svn: 210285
2014-05-30MachO: support N_INDR aliases in assembly files.Tim Northover1-0/+3
This makes LLVM create N_INDR aliases (to be resolved by the linker) when appropriate. rdar://problem/15125513 llvm-svn: 209894
2014-05-20Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSizeKevin Enderby1-3/+17
for undefined symbols, so it matches what COFFObjectFile::getSymbolAddress does. This allows llvm-nm to print spaces instead of 0’s for the value of undefined symbols in Mach-O files. To make this change other uses of MachOObjectFile::getSymbolAddress are updated to handle when the Value is returned as UnknownAddressOrSize. Which is needed to keep two of the ExecutionEngine tests working for example. llvm-svn: 209253
2014-05-20Revert r209235 as it broke two tests:Kevin Enderby1-10/+2
Failing Tests (2): LLVM :: ExecutionEngine/MCJIT/stubs-sm-pic.ll LLVM :: ExecutionEngine/MCJIT/stubs.ll llvm-svn: 209236
2014-05-20Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSizeKevin Enderby1-2/+10
for undefined symbols. Allowing llvm-nm to print spaces instead of 0’s for the value of undefined symbols in Mach-O files. llvm-svn: 209235
2014-05-19Implement MachOObjectFile::isSectionData() and MachOObjectFile::isSectionBSSKevin Enderby1-6/+12
so that llvm-size will total up all the sections in the Berkeley format. This allows for rough categorizations for Mach-O sections. And allows the total of llvm-size’s Berkeley and System V formats to be the same. llvm-svn: 209158
2014-05-12[RuntimeDyld] Add support for MachO __jump_table and __pointers sections, andLang Hames1-7/+15
SECTDIFF relocations on 32-bit x86. This fixes several of the MCJIT regression test failures that show up on 32-bit builds. <rdar://problem/16886294> llvm-svn: 208635
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-1/+2
instead of comparing to nullptr. llvm-svn: 206252
2014-04-04Add an assert that this is only used with .o files.Rafael Espindola1-2/+4
I am not sure how to get a relocation in a .dylib, but this function would return the wrong value if passed one. llvm-svn: 205592
2014-04-03Implement getRelocationAddress for MachO and ET_REL elf files.Rafael Espindola1-1/+9
With that, fix the symbolizer to work with any ELF file. llvm-svn: 205588
2014-04-03Implement macho relocation iterators with section number + relocation number.Rafael Espindola1-22/+20
This will make it possible to implement getRelocationAddress. llvm-svn: 205587
2014-04-03Fix llvm-objdump crash.Rafael Espindola1-4/+4
llvm-svn: 205581
2014-04-03Remove section_rel_empty. Just compare begin() and end() instead.Rafael Espindola1-10/+0
llvm-svn: 205577
2014-04-03Implement get getSymbolFileOffset with getSymbolAddress.Rafael Espindola1-23/+0
This has the following advantages: * Less code. * The old ELF implementation was wrong for non-relocatable objects. * The old ELF implementation (and I think MachO) was wrong for thumb. No current testcase since this is only used from MCJIT and it only uses relocatable objects and I don't think it supports thumb yet. llvm-svn: 205508
2014-04-03Remove getSymbolValue.Rafael Espindola1-5/+0
All existing users explicitly ask for an address or a file offset. llvm-svn: 205503
2014-04-03Revert "Fix a nomenclature error in llvm-nm."Rafael Espindola1-2/+1
This reverts commit r205479. It turns out that nm does use addresses, it is just that every reasonable relocatable ELF object has sections with address 0. I have no idea if those exist in reality, but it at least it shows that llvm-nm should use the name address. The added test was includes an unusual .o file with non 0 section addresses. I created it by hacking ELFObjectWriter.cpp. Really sorry for the churn. llvm-svn: 205493
2014-04-02Fix a nomenclature error in llvm-nm.Rafael Espindola1-1/+2
What llvm-nm prints depends on the file format. On ELF for example, if the file is relocatable, it prints offsets. If it is not, it prints addresses. Since it doesn't really need to care what it is that it is printing, use the generic term value. Fix or implement getSymbolValue to keep llvm-nm working. llvm-svn: 205479
2014-03-29ARM64: initial backend importTim Northover1-0/+22
This adds a second implementation of the AArch64 architecture to LLVM, accessible in parallel via the "arm64" triple. The plan over the coming weeks & months is to merge the two into a single backend, during which time thorough code review should naturally occur. Everything will be easier with the target in-tree though, hence this commit. llvm-svn: 205090
2014-03-21[RuntimeDyld] Allow processRelocationRef to process more than one relocation ↵Juergen Ributzka1-0/+10
entry at a time. Some targets require more than one relocation entry to perform a relocation. This change allows processRelocationRef to process more than one relocation entry at a time by passing the relocation iterator itself instead of just the relocation entry. Related to <rdar://problem/16199095> llvm-svn: 204439
2014-03-18Darwin: Add assembler directives to create version-min load commands.Jim Grosbach1-0/+13
Allow object files to be tagged with a version-min load command for iOS or MacOSX. Teach macho-dump to understand the version-min load commands for testcases. rdar://11337778 llvm-svn: 204190
2014-03-17[C++11] Introduce ObjectFile::symbols() to use range-based loops.Alexey Samsonov1-7/+7
Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3081 llvm-svn: 204031
2014-03-13[C++11] Introduce ObjectFile::sections().Alexey Samsonov1-5/+5
Summary: This adds ObjectFile::section_iterator_range, that allows to write range-based for-loops running over all sections of a given file. Several files from lib/ are converted to the new interface. Similar fixes should be applied to a variety of llvm-* tools. Reviewers: rafael Reviewed By: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3069 llvm-svn: 203799
2014-03-06Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles1-1/+1
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
2014-03-05[C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles1-1/+1
llvm-svn: 202957
2014-02-21Add a SymbolicFile interface between Binary and ObjectFile.Rafael Espindola1-6/+6
This interface allows IRObjectFile to be implemented without having dummy methods for all section and segment related methods. Both llvm-ar and llvm-nm are changed to use it. Unfortunately the mangler is still not plugged in since it requires some refactoring to make a Module hold a DataLayout. llvm-svn: 201881
2014-02-10Change the begin and end methods in ObjectFile to match the style guide.Rafael Espindola1-14/+14
llvm-svn: 201108
2014-02-04Remove unused SF_ThreadLocal.Rafael Espindola1-1/+0
llvm-svn: 200800
2014-01-31Simplify getSymbolFlags.Rafael Espindola1-8/+5
None of the object formats require extra parsing to compute these flags, so the method cannot fail. llvm-svn: 200574
2014-01-30Only ELF has a dynamic symbol table. Remove it from ObjectFile.Rafael Espindola1-10/+0
COFF has only one symbol table. MachO has a LC_DYSYMTAB, but that is not a symbol table, just extra info about the one symbol table (LC_SYMTAB). IR (coming soon) also has only one table. llvm-svn: 200488
2014-01-30Simplify the handling of iterators in ObjectFile.Rafael Espindola1-36/+13
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
2014-01-24Make ObjectFile ownership of the MemoryBuffer optional.Rafael Espindola1-9/+10
This allows llvm-ar to mmap the input files only once. llvm-svn: 200040
2014-01-21Be a bit more consistent about using ErrorOr when constructing Binary objects.Rafael Espindola1-10/+10
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
2013-12-06Fix a pair of array index checks.Eric Christopher1-2/+5
Patch by Marius Wachtler. llvm-svn: 196560
2013-11-02move getSymbolNMTypeChar to the one program that needs it: nm.Rafael Espindola1-37/+0
llvm-svn: 193933
2013-11-02Fix llvm-nm to mach OS X's nm on some tests.Rafael Espindola1-6/+17
There is still a long way to go for llvm-nm, but at least we now match nm's letter output in the cases we test for. llvm-svn: 193912
2013-09-27Object/COFF: Rename getXXX{Begin,End} -> xxx_{begin,end}.Rui Ueyama1-6/+6
It is mentioned in the LLVM coding standard that _begin() and _end() suffixes should be used. llvm-svn: 191569
2013-09-01Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis1-366/+372
llvm-svn: 189728
2013-08-27Revert "Fix the build broken by r189315." and "Move everything depending on ↵Charles Davis1-374/+368
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
2013-08-27Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis1-368/+374
llvm-svn: 189315
2013-08-27Support/MachO: Add a bunch of defines.Charles Davis1-26/+26
Right now we have two headers for the Mach-O format. I'd like to get rid of one. Since the other object formats are all in Support, I chose to keep the Mach-O header in Support, and discard the other one. llvm-svn: 189314
2013-08-21Move #includes from .h to .cpp file.Jakub Staszak1-0/+2
llvm-svn: 188852
2013-08-08initial draft of PPCMachObjectWriter.cppDavid Fang1-3/+4
this records relocation entries in the mach-o object file for PIC code generation. tested on powerpc-darwin8, validated against darwin otool -rvV llvm-svn: 188004
2013-08-03MachObjectFile: Don't leak on error.Benjamin Kramer1-7/+9
llvm-svn: 187698
2013-07-22Typo.Eric Christopher1-1/+1
llvm-svn: 186886
2013-07-2280-column tidying. Formatting choices by clang-format.Eric Christopher1-14/+16
llvm-svn: 186885
2013-06-18Basic support for parsing Mach-O universal binaries in LLVMObject libraryAlexey Samsonov1-2/+6
llvm-svn: 184191
2013-06-06Teach llvm-objdump with the -macho parser how to use the data in code tableKevin Enderby1-1/+45
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
2013-06-05Handle relocations that don't point to symbols.Rafael Espindola1-8/+5
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
2013-05-14Object: Fix Mach-O relocation printing.Ahmed Bougacha1-2/+3
There were two problems that made llvm-objdump -r crash: - for non-scattered relocations, the symbol/section index is actually in the (aptly named) symbolnum field. - sections are 1-indexed. llvm-svn: 181843
2013-05-09Change getRelocationAdditionalInfo to be ELF only.Rafael Espindola1-6/+0
It was only implemented for ELF where it collected the Addend, so this patch also renames it to getRelocationAddend. llvm-svn: 181502