summaryrefslogtreecommitdiff
path: root/lib/Object/COFFObjectFile.cpp
Commit message (Collapse)AuthorAge
* Simplify getSymbolFlags.Rafael Espindola2014-01-31
| | | | | | | None of the object formats require extra parsing to compute these flags, so the method cannot fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200574 91177308-0d34-0410-b5e6-96231b3b80d8
* Only ELF has a dynamic symbol table. Remove it from ObjectFile.Rafael Espindola2014-01-30
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200488 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify the handling of iterators in ObjectFile.Rafael Espindola2014-01-30
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200442 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm-readobj: add support for PE32+ (Windows 64 bit executable).Rui Ueyama2014-01-26
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200117 91177308-0d34-0410-b5e6-96231b3b80d8
* Make ObjectFile ownership of the MemoryBuffer optional.Rafael Espindola2014-01-24
| | | | | | This allows llvm-ar to mmap the input files only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200040 91177308-0d34-0410-b5e6-96231b3b80d8
* Be a bit more consistent about using ErrorOr when constructing Binary objects.Rafael Espindola2014-01-21
| | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199770 91177308-0d34-0410-b5e6-96231b3b80d8
* 80-column.Rui Ueyama2014-01-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199519 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm-objdump/COFF: Print ordinal base number.Rui Ueyama2014-01-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199518 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm-objdump/COFF: Print DLL name in the export table header.Rui Ueyama2014-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199422 91177308-0d34-0410-b5e6-96231b3b80d8
* Use static instead of anonymous namespace.Rui Ueyama2014-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199419 91177308-0d34-0410-b5e6-96231b3b80d8
* Reduce nesting.Rui Ueyama2014-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199418 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the current local variable naming style.Rui Ueyama2014-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199417 91177308-0d34-0410-b5e6-96231b3b80d8
* llmv-objdump/COFF: Print export table contents.Rui Ueyama2014-01-16
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199358 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use DataRefImpl to implement ImportDirectoryEntryRef.Rui Ueyama2014-01-16
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199349 91177308-0d34-0410-b5e6-96231b3b80d8
* Readobj: If NumbersOfSections is 0xffff, it's an COFF import library.Rui Ueyama2013-11-15
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194844 91177308-0d34-0410-b5e6-96231b3b80d8
* move getSymbolNMTypeChar to the one program that needs it: nm.Rafael Espindola2013-11-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193933 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert another use of getSymbolNMTypeChar.Rafael Espindola2013-11-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193932 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid some getSymbolNMTypeChar uses in COFFObjectFile.cpp itself.Rafael Espindola2013-11-02
| | | | | | This is a fixed version of 193928 which keeps these uses in sync. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193931 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Don't use getSymbolNMTypeChar for implementing ↵Rafael Espindola2013-11-02
| | | | | | | | | | COFFObjectFile::getSymbolFileOffset." Investigating a bot failure. This reverts commit r193928. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193929 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use getSymbolNMTypeChar for implementing ↵Rafael Espindola2013-11-02
| | | | | | COFFObjectFile::getSymbolFileOffset. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193928 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing #include's to cctype when using isdigit/alpha/etc.Will Dietz2013-10-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192519 91177308-0d34-0410-b5e6-96231b3b80d8
* Object/COFF: Rename getXXX{Begin,End} -> xxx_{begin,end}.Rui Ueyama2013-09-27
| | | | | | | It is mentioned in the LLVM coding standard that _begin() and _end() suffixes should be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191569 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-submit r191472 with a fix for big endian.Rui Ueyama2013-09-27
| | | | | | llvm-objdump: Dump COFF import table if -private-headers option is given. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191557 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "llvm-objdump: Dump COFF import table if -private-headers option is ↵Rui Ueyama2013-09-27
| | | | | | | | given." This reverts commit r191472 because it's failing on BE machine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191480 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm-objdump: Dump COFF import table if -private-headers option is given.Rui Ueyama2013-09-27
| | | | | | | | | | | | | | | | This is a patch to add capability to llvm-objdump to dump COFF Import Table entries, so that we can write tests for LLD checking Import Table contents. llvm-objdump did not print anything but just file name if the format is COFF and -private-headers option is given. This is a patch adds capability for dumping DLL Import Table, which is specific to the COFF format. In this patch I defined a new iterator to iterate over import table entries. Also added a few functions to COFFObjectFile.cpp to access fields of the entry. Differential Revision: http://llvm-reviews.chandlerc.com/D1719 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191472 91177308-0d34-0410-b5e6-96231b3b80d8
* Retry submitting r186623: COFFDumper: Dump data directory entries.Rui Ueyama2013-07-19
| | | | | | | | The original change was rolled back in r186627 because of test failures on the big endian machine. I believe I fixed the issue so re-submitting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186734 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "COFFDumper: Dump data directory entries."Rui Ueyama2013-07-18
| | | | | | Because it broke s390x and ppc64-linux buildbots. This reverts commit r186623. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186627 91177308-0d34-0410-b5e6-96231b3b80d8
* COFFDumper: Dump data directory entries.Rui Ueyama2013-07-18
| | | | | | | | | | | | | | | | | Summary: Dump optional data directory entries in the PE/COFF header, so that we can test the output of LLD linker. This patch updates the test binary file, but the source of the binary is the same. I just re-linked the file. I don't know how the previous file was linked, but the previous file did not have any data directory entries for some reason. Reviewers: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1148 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186623 91177308-0d34-0410-b5e6-96231b3b80d8
* readobj: Dump PE/COFF optional records.Rui Ueyama2013-06-12
| | | | | | | | | | | | These records are mandatory for executables and are used by the loader. Reviewers: rafael CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D939 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183852 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle relocations that don't point to symbols.Rafael Espindola2013-06-05
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183284 91177308-0d34-0410-b5e6-96231b3b80d8
* Change getRelocationAdditionalInfo to be ELF only.Rafael Espindola2013-05-09
| | | | | | | It was only implemented for ELF where it collected the Addend, so this patch also renames it to getRelocationAddend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181502 91177308-0d34-0410-b5e6-96231b3b80d8
* Clarify getRelocationAddress x getRelocationOffset a bit.Rafael Espindola2013-04-25
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180259 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused argument.Rafael Espindola2013-04-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178987 91177308-0d34-0410-b5e6-96231b3b80d8
* Add static cast to unsigned char whenever a character classification ↵Guy Benyei2013-02-12
| | | | | | function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175006 91177308-0d34-0410-b5e6-96231b3b80d8
* Add interface for querying object files for symbol values.Tim Northover2012-10-29
| | | | | | | | Currently only implemented for ELF. Patch by Amara Emerson. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166918 91177308-0d34-0410-b5e6-96231b3b80d8
* Cosmetic changesAndrew Kaylor2012-10-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165588 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch adds new functions to the SectionRef and ObjectFile interfaces to ↵Andrew Kaylor2012-10-10
| | | | | | | | determine whether or not a section is meant to be read-only. These functions will be used by the MCJIT RuntimeDyld to give hints to the memory manager during the object loading process in a future patch. Patch by Ashok Thirumurthi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165586 91177308-0d34-0410-b5e6-96231b3b80d8
* Added accessors for getting coff_relocation infoMarshall Clow2012-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158675 91177308-0d34-0410-b5e6-96231b3b80d8
* Had a closing brace inside an #ifdef -- oops!Marshall Clow2012-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158485 91177308-0d34-0410-b5e6-96231b3b80d8
* Adding acessors to COFFObjectFile so that clients can get at the ↵Marshall Clow2012-06-15
| | | | | | (non-generic) bits git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158484 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch improves the MCJIT runtime dynamic loader by adding new handlingPreston Gurd2012-04-12
| | | | | | | | | | | | of zero-initialized sections, virtual sections and common symbols and preventing the loading of sections which are not required for execution such as debug information. Patch by Andy Kaylor! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154610 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a constructor for DataRefImpl and remove excess initialization.Danil Malyshev2012-04-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154371 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object/COFF]: Expose getSectionContents.Michael J. Spencer2012-03-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153051 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object/COFF]: Expose getSectionName.Michael J. Spencer2012-03-19
| | | | | | Also add some documentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153050 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bug found by warning.Michael J. Spencer2012-03-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152812 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object]David Meyer2012-03-09
| | | | | | | | | Make Binary::TypeID more granular, to distinguish between ELF 32/64 little/big git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152435 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object]David Meyer2012-03-01
| | | | | | | | Add ObjectFile::getLoadName() for retrieving the soname/installname of a shared object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151845 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object]David Meyer2012-03-01
| | | | | | | | | | | * Add begin_dynamic_table() / end_dynamic_table() private interface to ELFObjectFile. * Add begin_libraries_needed() / end_libraries_needed() interface to ObjectFile, for grabbing the list of needed libraries for a shared object or dynamic executable. * Implement this new interface completely for ELF, leave stubs for COFF and MachO. * Add 'llvm-readobj' tool for dumping ObjectFile information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151785 91177308-0d34-0410-b5e6-96231b3b80d8
* [Object] Add symbol attribute flags: ST_ThreadLocal, ST_Common, and ↵David Meyer2012-02-29
| | | | | | | | | | | ST_Undefined. Implement these completely for ELF. Rename ST_External to ST_Unknown, and slightly change its semantics. It now only indicates that the symbol's type is unknown, not that the symbol is undefined. (For that, use ST_Undefined). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151696 91177308-0d34-0410-b5e6-96231b3b80d8
* In the ObjectFile interface, replace isInternal(), isAbsolute(), isGlobal(), ↵David Meyer2012-02-28
| | | | | | and isWeak(), with a bitset of flags. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151670 91177308-0d34-0410-b5e6-96231b3b80d8