summaryrefslogtreecommitdiffstats
path: root/llvm/tools/obj2yaml/macho2yaml.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [yaml2obj/obj2yaml][MachO] Allow setting custom section dataSeiya Nuta2019-08-201-15/+25
| | | | | | | | | | | | | | Reviewers: alexshap, jhenderson, rupprecht Reviewed By: alexshap, jhenderson Subscribers: abrachet, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65799 llvm-svn: 369348
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-1/+1
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Use delegation instead of inheritance.Rafael Espindola2017-07-191-4/+4
| | | | | | | | | | This changes DwarfContext to delegate to DwarfObject instead of having pure virtual methods. With this DwarfContextInMemory is replaced with an implementation of DwarfObject that is local to a .cpp file. llvm-svn: 308543
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-05-311-0/+2
| | | | llvm-svn: 304273
* Add LC_BUILD_VERSION load commandSteven Wu2017-01-231-0/+17
| | | | | | | | | | | | | | | | | | | Summary: Add a new load command LC_BUILD_VERSION. It is a generic version of LC_*_VERSION_MIN load_command used on Apple platforms. Instead of having a seperate load command for each platform, LC_BUILD_VERSION is recording platform info as an enum. It also records SDK version, min_os, and tools that used to build the binary. rdar://problem/29781291 Reviewers: enderby Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29044 llvm-svn: 292824
* [ObjectYAML] MachO support for endiannessChris Bieneman2016-12-221-9/+9
| | | | | | This patch adds support to the macho<->yaml tools for preserving endianness in MachO structures and DWARF data. llvm-svn: 290381
* [obj2yaml] Refactor and abstract dwarf2yamlChris Bieneman2016-12-071-41/+4
| | | | | | This makes the dwarf2yaml code separated and reusable allowing ELF and COFF to share implementations with MachO. llvm-svn: 288986
* [ObjectYAML] Pull DWARF support into DWARFYAML namespaceChris Bieneman2016-12-071-2/+2
| | | | | | | | Since DWARF formatting is agnostic to the object file it is stored in, it doesn't make sense for this to be in the MachOYAML implementation. Pulling it into its own namespace means we could modify the ELF and COFF YAML tools to emit DWARF as well. In a follow-up patch I will better abstract this in obj2yaml and yaml2obj so that the DWARF bits in the tools can be re-used too. llvm-svn: 288984
* [ObjectYAML] Support for DWARF __debug_abbrev sectionChris Bieneman2016-12-071-1/+28
| | | | | | This patch adds support for round-tripping DWARF debug abbreviations through the obj<->yaml tools. llvm-svn: 288955
* [ObjectYAML] First bit of support for encoding DWARF in MachOChris Bieneman2016-12-061-0/+19
| | | | | | This patch adds the starting support for encoding data from the MachO __DWARF segment. The first section supported is the __debug_str section because it is the simplest. llvm-svn: 288774
* [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-241-5/+34
| | | | | | 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
* [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
* [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
* [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-121-10/+16
| | | | | | 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-111-0/+35
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
OpenPOWER on IntegriCloud