summaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFObjectFile.cpp
AgeCommit message (Collapse)Author
2014-06-23Make ObjectFile and BitcodeReader always own the MemoryBuffer.Rafael Espindola
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
2014-06-13Remove 'using std::errro_code' from lib.Rafael Espindola
llvm-svn: 210871
2014-06-12Don't use 'using std::error_code' in include/llvm.Rafael Espindola
This should make sure that most new uses use the std prefix. llvm-svn: 210835
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper
instead of comparing to nullptr. llvm-svn: 206252
2014-04-09Object: add type names for ARM/COFF relocationsSaleem Abdulrasool
Add type name mappings for the ARM COFF relocations. This allows for objdump to provide a more useful description of relocations in disassembly inline form. llvm-svn: 205834
2014-04-03Remove section_rel_empty. Just compare begin() and end() instead.Rafael Espindola
llvm-svn: 205577
2014-04-03Implement get getSymbolFileOffset with getSymbolAddress.Rafael Espindola
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 Espindola
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 Espindola
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 Espindola
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-21[RuntimeDyld] Allow processRelocationRef to process more than one relocation ↵Juergen Ributzka
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-21Object/COFF: Support large relocation table.Rui Ueyama
NumberOfRelocations field in COFF section table is only 16-bit wide. If an object has more than 65535 relocations, the number of relocations is stored to VirtualAddress field in the first relocation field, and a special flag (IMAGE_SCN_LNK_NRELOC_OVFL) is set to Characteristics field. In test we cheated a bit. I made up a test file so that it has IMAGE_SCN_LNK_NRELOC_OVFL flag but the number of relocations is much smaller than 65535. This is to avoid checking in a large test file just to test a file with many relocations. Differential Revision: http://llvm-reviews.chandlerc.com/D3139 llvm-svn: 204418
2014-03-19Object: Provide a richer means of describing auxiliary symbolsDavid Majnemer
The current state of affairs has auxiliary symbols described as a big bag of bytes. This is less than satisfying, it detracts from the YAML file as being human readable. Instead, allow for symbols to optionally contain their auxiliary data. This allows us to have a much higher level way of describing things like weak symbols, function definitions and section definitions. This depends on D3105. Differential Revision: http://llvm-reviews.chandlerc.com/D3092 llvm-svn: 204214
2014-03-18Object/COFF: Add function to check if section number is reserved one.Rui Ueyama
Differential Revision: http://llvm-reviews.chandlerc.com/D3103 llvm-svn: 204199
2014-03-18[C++11] Change the interface of getCOFF{Section,Relocation,Symbol} to make ↵Alexey Samsonov
it work with range-based for loops. Reviewers: ruiu Reviewed By: ruiu CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3097 llvm-svn: 204120
2014-03-13Support: add support to identify WinCOFF/ARM objectsSaleem Abdulrasool
Add the Windows COFF ARM object file magic. This enables the LLVM tools to interact with COFF object files for Windows on ARM. llvm-svn: 203761
2014-03-06Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles
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 Charles
llvm-svn: 202957
2014-02-26Relax COFF string table checkNico Rieck
COFF object files with 0 as string table size are currently rejected. This prevents us from reading object files written by tools like cvtres that violate the PECOFF spec and write 0 instead of 4 for the size of an empty string table. llvm-svn: 202292
2014-02-25Simplify base64 routine a bit.Rui Ueyama
llvm-svn: 202210
2014-02-22MC: Support COFF string tables larger than 10MBNico Rieck
Offsets past the range of single-slash encoding are encoded as base64, padded to 6 characters, and prefixed with two slashes. This encoding is undocumented but used by MSVC. llvm-svn: 201940
2014-02-21Add a SymbolicFile interface between Binary and ObjectFile.Rafael Espindola
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-20cstdint is a C++11 header, LLVM provides its own version of it.Benjamin Kramer
Some versions of libstdc++ forbid using cstdint in C++98 mode. llvm-svn: 201812
2014-02-20Fix build breakage.Rui Ueyama
llvm-svn: 201805
2014-02-20Object/COFF: Fix possible truncation bug.Rui Ueyama
VA can be 64 bit, as the image base can be larger than 4GB, so we need to handle 64 bit VAs properly. llvm-svn: 201803
2014-02-20COFFObjectFile.cpp: Appease msvc in r201760.NAKAMURA Takumi
llvm-svn: 201769
2014-02-20llvm-objdump/COFF: Print SEH table addresses.Rui Ueyama
SEH table addresses are VA in COFF file. In this patch we convert VA to RVA before printing it, because dumpbin prints them as RVAs. llvm-svn: 201760
2014-02-10Change the begin and end methods in ObjectFile to match the style guide.Rafael Espindola
llvm-svn: 201108
2014-02-05Use the information provided by getFlags to unify some code in llvm-nm.Rafael Espindola
It is not clear how much we should try to expose in getFlags. For example, should there be a SF_Object and a SF_Text? But for information that is already being exposed, we may as well use it in llvm-nm. llvm-svn: 200820
2014-02-04Remove unused SF_ThreadLocal.Rafael Espindola
llvm-svn: 200800
2014-01-31Simplify getSymbolFlags.Rafael Espindola
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 Espindola
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 Espindola
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-26llvm-readobj: add support for PE32+ (Windows 64 bit executable).Rui Ueyama
PE32+ supports 64 bit address space, but the file format remains 32 bit. So its file format is pretty similar to PE32 (32 bit executable). The differences compared to PE32 are (1) the lack of "BaseOfData" field and (2) some of its data members are 64 bit. In this patch, I added a new member function to get a PE32+ Header object to COFFObjectFile class and made llvm-readobj to use it. llvm-svn: 200117
2014-01-24Make ObjectFile ownership of the MemoryBuffer optional.Rafael Espindola
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 Espindola
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
2014-01-1780-column.Rui Ueyama
llvm-svn: 199519
2014-01-17llvm-objdump/COFF: Print ordinal base number.Rui Ueyama
llvm-svn: 199518
2014-01-16llvm-objdump/COFF: Print DLL name in the export table header.Rui Ueyama
llvm-svn: 199422
2014-01-16Use static instead of anonymous namespace.Rui Ueyama
llvm-svn: 199419
2014-01-16Reduce nesting.Rui Ueyama
llvm-svn: 199418
2014-01-16Use the current local variable naming style.Rui Ueyama
llvm-svn: 199417
2014-01-16llmv-objdump/COFF: Print export table contents.Rui Ueyama
This patch adds the capability to dump export table contents. An example output is this: Export Table: Ordinal RVA Name 5 0x2008 exportfn1 6 0x2010 exportfn2 By adding this feature to llvm-objdump, we will be able to use it to check export table contents in LLD's tests. Currently we are doing binary comparison in the tests, which is fragile and not readable to humans. llvm-svn: 199358
2014-01-16Don't use DataRefImpl to implement ImportDirectoryEntryRef.Rui Ueyama
DataRefImpl (a union of two integers and a pointer) is not the ideal data type to represent a reference to an import directory entity. We should just use the pointer to the import table and an offset instead to simplify. No functionality change. llvm-svn: 199349
2013-11-15Readobj: If NumbersOfSections is 0xffff, it's an COFF import library.Rui Ueyama
0xffff does not mean that there are 65535 sections in a COFF file but indicates that it's a COFF import library. This patch fixes SEGV error when an import library file is passed to llvm-readobj. llvm-svn: 194844
2013-11-02move getSymbolNMTypeChar to the one program that needs it: nm.Rafael Espindola
llvm-svn: 193933
2013-11-02Convert another use of getSymbolNMTypeChar.Rafael Espindola
llvm-svn: 193932
2013-11-02Avoid some getSymbolNMTypeChar uses in COFFObjectFile.cpp itself.Rafael Espindola
This is a fixed version of 193928 which keeps these uses in sync. llvm-svn: 193931
2013-11-02Revert "Don't use getSymbolNMTypeChar for implementing ↵Rafael Espindola
COFFObjectFile::getSymbolFileOffset." Investigating a bot failure. This reverts commit r193928. llvm-svn: 193929
2013-11-02Don't use getSymbolNMTypeChar for implementing ↵Rafael Espindola
COFFObjectFile::getSymbolFileOffset. llvm-svn: 193928