summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove always false parameter.Rafael Espindola2015-07-211-5/+4
| | | | llvm-svn: 242802
* Use range loop. NFC.Rafael Espindola2015-07-211-3/+3
| | | | llvm-svn: 242801
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+20
| | | | | | | | | | SHT_NOBITS sections do not have content in an object file. Now the yaml2obj tool does not accept `Content` field for such sections, and the obj2yaml tool does not attempt to read the section content from a file. Restore r241350 and r241352. llvm-svn: 241377
* This reverts commit r241350 and r241352.Rafael Espindola2015-07-031-20/+0
| | | | | | | | | | | r241350 broke lld tests. r241352 depends on r241350. Original messages: "[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools" "[ELFYAML] Make the Size field for .bss section optional" llvm-svn: 241354
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+20
| | | | | | | | SHT_NOBITS sections do not have content in an object file. Now yaml2obj tool does not accept `Content` field for such sections, and obj2yaml tool does not attempt to read the section content from a file. llvm-svn: 241350
* Return ErrorOr from SymbolRef::getName.Rafael Espindola2015-07-021-1/+4
| | | | | | | | | | | | This function can really fail since the string table offset can be out of bounds. Using ErrorOr makes sure the error is checked. Hopefully a lot of the boilerplate code in tools/* can go away once we have a diagnostic manager in Object. llvm-svn: 241297
* Return ErrorOr from getSection.Rafael Espindola2015-07-011-20/+34
| | | | | | | | | | | | | | This also improves the logic of what is an error: * getSection(uint_32): only return an error if the index is out of bounds. The index 0 corresponds to a perfectly valid entry. * getSection(Elf_Sym): Returns null for symbols that normally don't have sections and error for out of bound indexes. In many places this just moves the report_fatal_error up the stack, but those can then be fixed in smaller patches. llvm-svn: 241156
* Fix the name of the iterator functions to match the coding standards.Rafael Espindola2015-06-301-4/+3
| | | | llvm-svn: 241074
* Convert obj->getSymbolName to sym->getName.Rafael Espindola2015-06-291-2/+2
| | | | | | I doesn't depend on the object anymore. llvm-svn: 240996
* Factor out the checking of string tables.Rafael Espindola2015-06-291-2/+10
| | | | | | | | | | This moves the error checking for string tables to getStringTable which returns an ErrorOr<StringRef>. This improves error checking, makes it uniform across all string tables and makes it possible to check them once instead of once per name. llvm-svn: 240950
* Remove Elf_Sym_Iter.Rafael Espindola2015-06-291-8/+11
| | | | | | | | | | | | | | | | | | | It was a fairly broken concept for an ELF only class. An ELF file can have two symbol tables, but they have exactly the same format. There is no concept of a dynamic or a static symbol. Storing this on the iterator also makes us do more work per symbol than necessary. To fetch a name we would: * Find if we had a static or a dynamic symbol. * Look at the corresponding symbol table and find the string table section. * Look at the string table section to fetch its contents. * Compute the name as a substring of the string table. All but the last step can be done per symbol table instead of per symbol. This is a step in that direction. llvm-svn: 240939
* Remove object_error::success and use std::error_code() insteadRui Ueyama2015-06-092-2/+2
| | | | | | | | | | | | make_error_code(object_error) is slow because object::object_category() uses a ManagedStatic variable. But the real problem is that the function is called too frequently. This patch uses std::error_code() instead of object_error::success. In most cases, we return "success", so this patch reduces number of function calls to that function. http://reviews.llvm.org/D10333 llvm-svn: 239409
* [obj2yaml/yaml2obj] Add SHT_MIPS_ABIFLAGS section supportSimon Atanasyan2015-05-071-0/+37
| | | | | | | This change adds support for the SHT_MIPS_ABIFLAGS section reading/writing to the obj2yaml and yaml2obj tools. llvm-svn: 236738
* [obj2yaml/yaml2obj] Add SHT_GROUP support.Shankar Easwaran2015-02-211-1/+45
| | | | | | This adds section group support to the tools obj2yaml and yaml2obj. llvm-svn: 230124
* obj2yaml, yaml2obj: Add support for COFF executablesDavid Majnemer2014-11-141-13/+72
| | | | | | | | | | | | | | | | In support of serializing executables, obj2yaml now records the virtual address and size of sections. It also serializes whatever we strictly need from the PE header, it expects that it can reconstitute everything else via inference. yaml2obj can reconstitute a fully linked executable. In order to get executables correctly serialized/deserialized, other bugs were fixed as a circumstance. We now properly respect file and section alignments. We also avoid writing out string tables unless they are strictly necessary. llvm-svn: 221975
* [ELF][yaml2obj] Handle additional MIPS specific st_other field flagsSimon Atanasyan2014-11-061-1/+1
| | | | | | | | The ELF symbol `st_other` field might contain additional flags besides visibility ones. This patch implements support for some MIPS specific flags. llvm-svn: 221491
* Add accessor to get 'visibility' part of st_other fieldSimon Atanasyan2014-11-051-1/+1
| | | | | | This new `getVisibility()` function will also be used in the LLD code. llvm-svn: 221392
* Object, COFF: Cleanup symbol type code, improve binutils compatibilityDavid Majnemer2014-10-311-1/+1
| | | | | | | Do a better job classifying symbols. This increases the consistency between the COFF handling code and the ELF side of things. llvm-svn: 220952
* obj2yaml, COFF: Handle long section namesDavid Majnemer2014-10-101-5/+5
| | | | | | | | | | | | | Long section names are represented as a slash followed by a numeric ASCII string. This number is an offset into a string table. Print the appropriate entry in the string table instead of the less enlightening /4. N.B. yaml2obj already does the right thing, this test exercises both sides of the (de-)serialization. llvm-svn: 219458
* MC: Add support for BigObjDavid Majnemer2014-09-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Teach WinCOFFObjectWriter how to write -mbig-obj style object files; these object files allow for more sections inside an object file. Our support for BigObj is notably different from binutils and cl: we implicitly upgrade object files to BigObj instead of asking the user to compile the same file *again* but with another flag. This matches up with how LLVM treats ELF variants. This was tested by forcing LLVM to always emit BigObj files and running the entire test suite. A specific test has also been added. I've lowered the maximum number of sections in a normal COFF file, VS "14" CTP 3 supports no more than 65279 sections. This is important otherwise we might not switch to BigObj quickly enough, leaving us with a COFF file that we couldn't link. yaml2obj support is all that remains to implement. Differential Revision: http://reviews.llvm.org/D5349 llvm-svn: 217812
* Added missing LLVM_NOEXCEPT to the definition of _obj2yaml_error_category::nameIsmail Pazarbasi2014-09-111-1/+3
| | | | | | LLVM_NOEXCEPT was added in r210591. llvm-svn: 217603
* Object: Add support for bigobjDavid Majnemer2014-09-101-38/+32
| | | | | | | | | | | | | | | | | | | | | | 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
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Canonicalize header guards into a common format.Benjamin Kramer2014-08-132-4/+4
| | | | | | | | | | 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
* Remove some calls to std::move.Rafael Espindola2014-08-011-2/+2
| | | | | | | | | 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
* Use std::unique_ptr to make the ownership explicit.Rafael Espindola2014-07-311-2/+2
| | | | llvm-svn: 214377
* Install the `obj2yaml` and `yaml2obj` utilities together with other LLVM tools.Simon Atanasyan2014-07-292-4/+1
| | | | llvm-svn: 214191
* Invert the MC -> Object dependency.Rafael Espindola2014-07-032-2/+2
| | | | | | | | | Now that we have a lib/MC/MCAnalysis, the dependency was there just because of two helper classes. Move the two over to MC. This will allow IRObjectFile to parse inline assembly. llvm-svn: 212248
* Remove unused and odd code.Rafael Espindola2014-06-131-9/+0
| | | | | | | | This code was never being used and any use of it would look fairly strange. For example, it would try to map a object_error::parse_failed to std::errc::invalid_argument. llvm-svn: 210912
* Remove 'using std::error_code' from tools.Rafael Espindola2014-06-133-42/+41
| | | | llvm-svn: 210876
* Remove all uses of 'using std::error_code' from headers.Rafael Espindola2014-06-133-3/+4
| | | | llvm-svn: 210866
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove system_error.h.Rafael Espindola2014-06-122-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
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-4/+4
| | | | llvm-svn: 210783
* Don't import error_category into the llvm namespace.Rafael Espindola2014-06-122-3/+3
| | | | llvm-svn: 210733
* Don't import error_condition into the llvm namespace.Rafael Espindola2014-06-121-3/+4
| | | | llvm-svn: 210731
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-112-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use an enum class.Rafael Espindola2014-06-112-18/+9
| | | | llvm-svn: 210620
* Mark a few functions noexcept.Rafael Espindola2014-06-101-2/+2
| | | | | | This reduces the difference between std::error_code and llvm::error_code. llvm-svn: 210591
* [yaml2obj][obj2yaml] Support ELF symbol's visibility flags ↵Simon Atanasyan2014-06-061-0/+1
| | | | | | (default/hidden/protected). llvm-svn: 210316
* There is no std::errc::success, remove the llvm one.Rafael Espindola2014-05-311-1/+1
| | | | llvm-svn: 209960
* [elf2yaml][ELF] Move Info field to the RelocationSection structure. ThisSimon Atanasyan2014-05-291-9/+22
| | | | | | | field represents ELF section header sh_info field and does not have any sense for regular sections. Its interpretation depends on section type. llvm-svn: 209801
* [yaml2obj][ELF] Add an optional `Size` field to the YAML section declaration.Simon Atanasyan2014-05-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the only method to configure ELF section's content and size is to assign a hexadecimal string to the `Content` field. Unfortunately this way is completely useless when you need to declare a really large section. To solve this problem this patch adds one more optional field `Size` to the `RawContentSection` structure. When yaml2obj generates an ELF file it uses the following algorithm: 1. If both `Content` and `Size` fields are missed create an empty section. 2. If only `Content` field is missed take section length from the `Size` field and fill the section by zero. 3. If only `Size` field is missed create a section using data from the `Content` field. 4. If both `Content` and `Size` fields are provided validate that the `Size` value is not less than size of `Content` data. Than take section length from the `Size`, fill beginning of the section by `Content` and the rest by zero. Examples -------- * Create a section 0x10000 bytes long filled by zero Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Size: 0x10000 * Create a section 0x10000 bytes long starting from 'CA' 'FE' 'BA' 'BE' Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Content: CAFEBABE Size: 0x10000 The patch reviewed by Michael Spencer. llvm-svn: 208995
* [obj2yaml] Support ELF input format in the obj2yaml tool.Simon Atanasyan2014-05-144-1/+294
| | | | | | | | | | The ELF header e_flags field in the MIPS related test cases handled incorrectly. The obj2yaml prints too many flags. I will fix that in the next patches. The patch reviewed by Michael Spencer and Sean Silva. llvm-svn: 208752
* [obj2yaml] Recognize input file format using llvm::object::ObjectFileSimon Atanasyan2014-05-076-25/+126
| | | | | | | | | | | interface methods isCOFF(). The '-coff' command line option has been removed. It was not used in any test cases. The patch reviewed by Michael Spencer. llvm-svn: 208157
* Object: Output .file symbols properlyDavid Majnemer2014-03-201-1/+2
| | | | | | | obj2yaml would emit the NUL bytes padding the auxiliary file symbol records. Trimming them looks nicer. llvm-svn: 204314
* Object: Abstract out the determination of function line symbolsDavid Majnemer2014-03-201-1/+1
| | | | | | No functionality change. llvm-svn: 204313
* Object: Provide a richer means of describing auxiliary symbolsDavid Majnemer2014-03-191-1/+111
| | | | | | | | | | | | | | | | 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
* [C++11] Change the interface of getCOFF{Section,Relocation,Symbol} to make ↵Alexey Samsonov2014-03-181-10/+7
| | | | | | | | | | | | | | 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
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-2/+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
OpenPOWER on IntegriCloud