summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml/coff2yaml.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Resubmit "[codeview] Make obj2yaml/yaml2obj support .debug$S..."Zachary Turner2017-06-141-0/+57
| | | | | | | | | This was originally reverted because of some non-deterministic failures on certain buildbots. Luckily ASAN eventually caught this as a stack-use-after-scope, so the fix is included in this patch. llvm-svn: 305393
* Revert "[codeview] Make obj2yaml/yaml2obj support .debug$S..."Zachary Turner2017-06-141-57/+0
| | | | | | | | This is causing failures on linux bots with an invalid stream read. It doesn't repro in any configuration on Windows, so reverting until I have a chance to investigate on Linux. llvm-svn: 305371
* [codeview] Make obj2yaml/yaml2obj support .debug$S/T sections.Zachary Turner2017-06-141-0/+57
| | | | | | | | | | | | | | | This allows us to use yaml2obj and obj2yaml to round-trip CodeView symbol and type information without having to manually specify the bytes of the section. This makes for much easier to maintain tests. See the tests under lld/COFF in this patch for example. Before they just said SectionData: <blob> whereas now we can use meaningful record descriptions. Note that it still supports the SectionData yaml field, which could be useful for initializing a section to invalid bytes for testing, for example. Differential Revision: https://reviews.llvm.org/D34127 llvm-svn: 305366
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-201-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
* [obj2yaml, COFF] Assert that the alignment is not bogusDavid Majnemer2016-03-181-0/+1
| | | | llvm-svn: 263839
* Move ObjectYAML code to a new library.Rafael Espindola2016-03-011-1/+1
| | | | | | | It is only ever used by obj2yaml and yaml2obj. No point in linking it everywhere. llvm-svn: 262368
* 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
* Remove object_error::success and use std::error_code() insteadRui Ueyama2015-06-091-1/+1
| | | | | | | | | | | | 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 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
* 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
* 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
* Invert the MC -> Object dependency.Rafael Espindola2014-07-031-1/+1
| | | | | | | | | 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 'using std::error_code' from tools.Rafael Espindola2014-06-131-3/+2
| | | | llvm-svn: 210876
* 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
* [obj2yaml] Recognize input file format using llvm::object::ObjectFileSimon Atanasyan2014-05-071-4/+1
| | | | | | | | | | | 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
* Change the begin and end methods in ObjectFile to match the style guide.Rafael Espindola2014-02-101-6/+6
| | | | llvm-svn: 201108
* Simplify the handling of iterators in ObjectFile.Rafael Espindola2014-01-301-7/+3
| | | | | | | | | | | | 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
* Remove several unused variables.Rafael Espindola2013-10-011-1/+0
| | | | | | Patch by Alp Toker. llvm-svn: 191757
* readobj: Dump PE/COFF optional records.Rui Ueyama2013-06-121-1/+1
| | | | | | | | | | | | 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 llvm-svn: 183852
* Print symbol names in relocations when dumping COFF as YAML.Rafael Espindola2013-06-061-3/+5
| | | | llvm-svn: 183403
* Move BinaryRef to a new include/llvm/Object/YAML.h file.Rafael Espindola2013-06-051-2/+2
| | | | | | It will be used for ELF dumping too. llvm-svn: 183287
* Rename COFFYaml.h to COFFYAML.h for consistency.Rafael Espindola2013-05-311-1/+1
| | | | llvm-svn: 183042
* Don't allocate temporary string for section data.Rafael Espindola2013-05-311-18/+2
| | | | llvm-svn: 183040
* Use std::list so that we have a stable iterator.Rafael Espindola2013-05-211-1/+3
| | | | | | | I will try to avoid creating these std::strings, but for now this gets the tests passing with libc++. llvm-svn: 182405
* Convert obj2yaml to use yamlio.Rafael Espindola2013-05-171-305/+83
| | | | llvm-svn: 182169
* Remove dead code.Rafael Espindola2013-04-201-4/+0
| | | | | | | | | This is part of a future patch to use yamlio that incorrectly ended up in a cleanup patch. Thanks to Benjamin Kramer for reporting it. llvm-svn: 179938
* These can be void.Rafael Espindola2013-04-201-12/+7
| | | | llvm-svn: 179923
* Rename obj2yaml local namespace to avoid conflicts with llvm::yaml.Rafael Espindola2013-04-201-5/+5
| | | | llvm-svn: 179922
* Remove local namespace yaml to avoid confusion with llvm::yaml.Rafael Espindola2013-04-201-8/+6
| | | | llvm-svn: 179921
* Small obj2yaml cleanups.Rafael Espindola2013-04-201-69/+76
| | | | | | | | * using namespace llvm. * whitespace. * early return. llvm-svn: 179920
* Remove a global 'endl' variable from the other file as well.Chandler Carruth2013-04-081-25/+22
| | | | llvm-svn: 179010
* Move obj2yaml to tools to sort out make's dependencies.Rafael Espindola2013-04-051-0/+361
llvm-svn: 178835
OpenPOWER on IntegriCloud