summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Convert ELF.h to Expected<T>.Davide Italiano2016-11-161-71/+71
| | | | | | | | | | | | This has two advantages: 1) We slowly move away from ErrorOr to the new handling interface, in the hope of having an uniform error handling in LLVM, eventually. 2) We're starting to have *meaningful* error messages for invalid object ELF files, rather than a generic "parse error". At some point we should include also the offset to improve the quality of the diagnostic. llvm-svn: 287081
* Remove the last use of report_fatal_error from ELF.h.Rafael Espindola2016-11-031-2/+8
| | | | llvm-svn: 285955
* Add error handling to getEntry.Rafael Espindola2016-11-031-1/+4
| | | | | | Issue found by inspection. llvm-svn: 285951
* Replace a report_fatal_error with an ErrorOr.Rafael Espindola2016-11-031-1/+4
| | | | llvm-svn: 285905
* [tools/obj2yaml] - Update after LLVM change r285886George Rimar2016-11-031-1/+4
| | | | llvm-svn: 285887
* Avoid a report_fatal_error in sections().Rafael Espindola2016-11-021-1/+4
| | | | | | | Have it return a ErrorOr<Range> and delete section_begin and section_end. llvm-svn: 285807
* Remove LLVM_NOEXCEPT and replace it with noexceptReid Kleckner2016-10-191-2/+2
| | | | | | | Now that we have dropped MSVC 2013, all supported compilers support noexcept and we can drop this portability macro. llvm-svn: 284672
* Use range loop. NFC.Rafael Espindola2016-10-061-6/+7
| | | | llvm-svn: 283447
* [macho2yaml] String table can contain null stringsChris Bieneman2016-08-041-2/+0
| | | | | | | | Since the string table being read from the MachO is a properly bounded StringRef including null strings is safe and reasonable. This occurs frequently with stripped binaries where the string table has been modified. llvm-svn: 277753
* [yaml2obj] Remove --format option in favor of YAML tagsChris Bieneman2016-06-271-5/+8
| | | | | | | | | | | | | | | | | | | | | | Summary: Our YAML library's handling of tags isn't perfect, but it is good enough to get rid of the need for the --format argument to yaml2obj. This patch does exactly that. Instead of requiring --format, it infers the format based on the tags found in the object file. The supported tags are: !ELF !COFF !mach-o !fat-mach-o I have a corresponding patch that is quite large that fixes up all the in-tree test cases. Reviewers: rafael, Bigcheese, compnerd, silvas Subscribers: compnerd, llvm-commits Differential Revision: http://reviews.llvm.org/D21711 llvm-svn: 273915
* [obj2yaml] [yaml2obj] Support for MachO Universal binariesChris Bieneman2016-06-243-8/+39
| | | | | | This patch adds round-trip support for MachO Universal binaries to obj2yaml and yaml2obj. Universal binaries have a header and list of architecture structures, followed by a the individual object files at specified offsets. llvm-svn: 273719
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+1
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* [obj2yaml] [yaml2obj] Support for MachO nlist and string tableChris Bieneman2016-06-021-0/+37
| | | | | | This commit adds round tripping for MachO symbol data. Symbols are entries in the name list, that contain offsets into the string table which is at the end of the __LINKEDIT segment. llvm-svn: 271604
* [obj2yaml][yaml2obj] Support for reading and dumping the MachO export trieChris Bieneman2016-05-311-9/+131
| | | | | | The MachO export trie is a serially encoded trie keyed by symbol name. This code parses the trie and preserves the structure so that it can be dumped again. llvm-svn: 271300
* Remove some 'const' specifiers that do nothing but prevent moving the argument.Benjamin Kramer2016-05-291-1/+1
| | | | | | | Found by clang-tidy's misc-move-const-arg. While there drop some obsolete c_str() calls. llvm-svn: 271181
* [obj2yaml][yaml2obj] Support for MachO lazy bindingsChris Bieneman2016-05-261-0/+2
| | | | | | This adds support for YAML round tripping dyld info lazy bindings. The storage and format of these is the same as regular bind opcodes, they are just interpreted differently by dyld, and can have DONE opcodes in the middle of the opcode lists. llvm-svn: 270920
* [obj2yaml][yaml2obj] Support for MachO weak bindingsChris Bieneman2016-05-261-0/+2
| | | | | | This adds support for YAML round tripping dyld info weak bindings. The storage and format of these is the same as regular bind opcodes, they are just interpreted differently by dyld. llvm-svn: 270911
* [obj2yaml][yaml2obj] Support for MachO bind opcodesChris Bieneman2016-05-261-0/+66
| | | | | | This adds support for YAML round tripping dyld info bind opcodes. Bind opcodes can have signed or unsigned LEB128 data, and they can have symbols associated with them. llvm-svn: 270901
* [obj2yaml] [yaml2obj] MachO support for rebase opcodesChris Bieneman2016-05-251-1/+53
| | | | | | This is the first bit of support for MachO __LINKEDIT segment data. llvm-svn: 270724
* Add FIXMEs to all derived classes of std::error_category.Peter Collingbourne2016-05-241-0/+3
| | | | | | | | This helps make clear that we're moving away from std::error_code. Differential Revision: http://reviews.llvm.org/D20592 llvm-svn: 270604
* [obj2yaml] [yaml2obj] Support for MachO Load Command dataChris Bieneman2016-05-191-12/+68
| | | | | | | | | | | | | | This re-applies r270115. Many of the MachO load commands can have data appended after the command structure. This data is frequently strings, but can actually be anything. This patch adds support for three optional fields on load command yaml descriptions. The new PayloadString YAML field is populated with the data after load commands known to have strings as extra data. The new ZeroPadBytes YAML field is a count of zero'd bytes after the end of the load command structure before the next command. This can apply anywhere in the file. MachO2YAML verifies that bytes are zero before populating this field, and YAML2MachO will add zero'd bytes. The new PayloadBytes YAML field stores all bytes after the end of the load command structure before the next command if they are non-zero. This is a catch all for all unhandled bytes. If MachO2Yaml populates PayloadBytes it will not populate ZeroPadBytes, instead zero'd bytes will be in the PayloadBytes structure. llvm-svn: 270124
* Revert "[obj2yaml] [yaml2obj] Support for MachO Load Command data"Chris Bieneman2016-05-191-68/+12
| | | | | | | | This reverts commit r270115. This failed on several builders using GCC. llvm-svn: 270121
* [obj2yaml] [yaml2obj] Support for MachO Load Command dataChris Bieneman2016-05-191-12/+68
| | | | | | | | | | | | Many of the MachO load commands can have data appended after the command structure. This data is frequently strings, but can actually be anything. This patch adds support for three optional fields on load command yaml descriptions. The new PayloadString YAML field is populated with the data after load commands known to have strings as extra data. The new ZeroPadBytes YAML field is a count of zero'd bytes after the end of the load command structure before the next command. This can apply anywhere in the file. MachO2YAML verifies that bytes are zero before populating this field, and YAML2MachO will add zero'd bytes. The new PayloadBytes YAML field stores all bytes after the end of the load command structure before the next command if they are non-zero. This is a catch all for all unhandled bytes. If MachO2Yaml populates PayloadBytes it will not populate ZeroPadBytes, instead zero'd bytes will be in the PayloadBytes structure. llvm-svn: 270115
* [obj2yaml] Refactoring of dumping MachO section structsChris Bieneman2016-05-181-34/+44
| | | | | | This refactoring is to reduce code duplication between the 32-bit and 64-bit code paths. This refactoring will also make the special casing for other data after load commands cleaner. llvm-svn: 270001
* Re-apply: [obj2yaml] [yaml2obj] Support MachO section and section_64Chris Bieneman2016-05-181-0/+54
| | | | | | This re-applies r269845, r269846, and r269850 with an included fix for a crash reported by zturner. llvm-svn: 269953
* Revert "[obj2yaml] [yaml2obj] Support MachO section and section_64Zachary Turner2016-05-171-54/+0
| | | | | | | | | structs" This reverts commits r269845, r269846, and r269850 as they introduce a crash in obj2yaml when trying to do a roundtrip. llvm-svn: 269865
* [obj2yaml] [yaml2obj] Support MachO section and section_64 structsChris Bieneman2016-05-171-0/+54
| | | | | | This patch adds round trip support for MachO section structs. llvm-svn: 269845
* Reapply r269782 "[obj2yaml] [yaml2obj] Support for MachO load command ↵Chris Bieneman2016-05-171-5/+20
| | | | | | | | structures"" This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next. llvm-svn: 269808
* Revert "[obj2yaml] [yaml2obj] Support for MachO load command structures"Chris Bieneman2016-05-171-20/+5
| | | | | | This reverts commit r269782 because it broke bots with -fpermissive. llvm-svn: 269785
* [obj2yaml] [yaml2obj] Support for MachO load command structuresChris Bieneman2016-05-171-5/+20
| | | | | | This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next. llvm-svn: 269782
* macho2yaml.cpp: Fix "reserved" uninitialized.NAKAMURA Takumi2016-05-161-0/+1
| | | | | FIXME: It should reflect actual field. llvm-svn: 269645
* [obj2yaml] [yaml2obj] Basic support for MachO::load_commandChris Bieneman2016-05-131-3/+10
| | | | | | | | This patch adds basic support for MachO::load_command. Load command types and sizes are encoded in the YAML and expanded back into MachO. The YAML doesn't yet support load command structs, that is coming next. In the meantime as a temporary measure when writing MachO files the load commands are padded with zeros so that the generated binary is valid. llvm-svn: 269442
* [obj2yaml] Fix ASAN bot failureChris Bieneman2016-05-121-4/+4
| | | | | | | | I was leaking out of a unique_ptr, should have just kept it in the unique_ptr. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12738/steps/check-llvm%20asan/logs/stdio llvm-svn: 269336
* [obj2yaml] Include all mach_header fields in yamlChris Bieneman2016-05-121-0/+2
| | | | | | Since we want to be able to use yaml to describe degenerate object files as well as valid ones, we need to be explicit of some fields in your yaml definitions. llvm-svn: 269313
* [macho2yaml] Add support for dumping mach_headersChris Bieneman2016-05-121-1/+29
| | | | | | | | | | | | | | | This patch adds the ability to dump mach headers. For my local clang binary the macho2yaml output is now: --- !mach-o FileHeader: cputype: 0x01000007 cpusubtype: 0x80000003 filetype: 0x00000002 ncmds: 19 flags: 0x00A18085 ... llvm-svn: 269304
* [obj2yaml] Adding Error/Expected to macho2yamlChris Bieneman2016-05-123-11/+45
| | | | | | I figure if I'm adding Mach support I may as well use the new fancy Error model. llvm-svn: 269264
* Initial add for MachO support for obj2yamlChris Bieneman2016-05-116-2/+48
| | | | | | | | Adding the initial files for adding MachO support to obj2yaml. Passing a MachO file will result in a new not_implemented error. I will be implementing obj2yaml and yaml2obj for MachO in parallel so that one can be used to test the other. llvm-svn: 269243
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-202-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. 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(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp 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: 265606
* [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-013-2/+3
| | | | | | | It is only ever used by obj2yaml and yaml2obj. No point in linking it everywhere. llvm-svn: 262368
* Remove autoconf supportChris Bieneman2016-01-261-17/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* [obj2yaml] Fix "time of check to time of use" bug. Add a test.Davide Italiano2015-09-191-3/+0
| | | | llvm-svn: 248096
* Pass a symbol table to getRelocationSymbol instead of returning one.Rafael Espindola2015-09-021-11/+17
| | | | | | | This removes a report_fatal_error from library and avoids checking a section property for every section entry. llvm-svn: 246656
* Don't iterate over all sections in the ELFFile constructor.Rafael Espindola2015-08-101-7/+16
| | | | | | | With this we finally have an ELFFile that is O(1) to construct. This is helpful for programs like lld which have to do their own section walk. llvm-svn: 244510
* elf2yaml: Use existing section walk to find the symbol table. NFC.Rafael Espindola2015-08-101-4/+7
| | | | llvm-svn: 244447
* Remove the symbol iteration functions that don't take a symbol table.Rafael Espindola2015-08-071-1/+1
| | | | | | Another step in making ELFFile's constructor not iterate over all sections. llvm-svn: 244351
* Use helper function. NFC.Rafael Espindola2015-07-231-4/+1
| | | | llvm-svn: 243012
* Add a version of getSymbol with an explicit symbol table. Use it. NFC.Rafael Espindola2015-07-231-4/+5
| | | | llvm-svn: 243011
* Remove getStaticSymbolName.Rafael Espindola2015-07-211-3/+11
| | | | | | Every user now keeps track of the correct string table to use. llvm-svn: 242818
OpenPOWER on IntegriCloud