Commit Graph

38 Commits

Author SHA1 Message Date
Alex Bradbury
49b5e6b8a4 [RISCV] Add RISC-V ELF defines
Add the necessary definitions for RISC-V ELF files, including relocs. Also 
make necessary trivial change to ELFYaml, llvm-objdump, and llvm-readobj in 
order to work with RISC-V ELFs.

Differential Revision: https://reviews.llvm.org/D23557


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285708 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-01 16:59:37 +00:00
Chris Bieneman
506857f427 [macho2yaml] Don't write empty linkedit data
Since I stopped writing empty export tries it causes LinkEdit to potentially be completely empty which results in invalid yaml being generated.

To prevent this we skip linkedit data if it is empty.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278985 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 21:46:04 +00:00
Chris Bieneman
50b70a6871 [MachOYAML] Don't output empty ExportTrie
The YAML representation was always outputting the root node of an export trie even if the trie was empty. While this doesn't really have any functional impact, it does add visual clutter to the yaml file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278307 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 00:20:03 +00:00
Alexei Starovoitov
36b9c09330 BPF: Use official ELF e_machine value
The same value for EM_BPF is being propagated to glibc,
elfutils, and binutils.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275633 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:27:55 +00:00
Chris Bieneman
efed5fba68 [YAML] Fix YAML tags appearing before the start of sequence elements
Our existing yaml::Output code writes tags immediately when mapTag is called, without any state handling. This results in tags on sequence elements being written before the element itself. For example, we see this:

SomeArray:     !elem_type
  - key1:         1
    key2:         2 !elem_type2
  - key3:         3
    key4:         4

We should instead see:

SomeArray:
  - !elem_type
    key1:         1
    key2:         2
  - !elem_type2
    key3:         3
    key4:         4

Our reader handles reading properly, so this bug only impacts writing yaml sequences with tagged elements.

As a test for this I've modified the Mach-O yaml encoding to allways apply the !mach-o tag when encoding MachOYAML::Object entries. This results in the !mach-o tag appearing as expected in dumped fat files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274067 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 21:10:26 +00:00
Chris Bieneman
9cf90e65d1 [yaml2obj] Remove --format option in favor of YAML tags
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273915 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 19:53:53 +00:00
Chris Bieneman
e92acf1526 [obj2yaml] [yaml2obj] Support for MachO Universal binaries
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273719 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 20:42:28 +00:00
Chris Bieneman
072362b093 [MachOYAML] Use a temporary to avoid gcc strict-aliasing warning
GCC complains about this with -Wstrict-aliasing. Using a temporary here should prevent the warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273627 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 23:01:47 +00:00
Chris Bieneman
46c1e8f8c6 [yaml2macho] Removing asserts in favor of explicit yaml parse error
32-bit Mach headers don't have reserved fields. When generating the
mapping for 32-bit headers leaving off the reserved field will result in
parse errors if the field is present in the yaml.

Added a CHECK-NOT line to ensure that mach_header.yaml isn't adding a
reserved field, and a test to ensure that the parser error gets hit with
32-bit headers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273623 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-23 22:36:31 +00:00
Tom Stellard
7dc79e5898 Support/ELF: Add AMDGPU relocation definitions to match documentation
Reviewers: arsenm, kzhuravl, rafael

Subscribers: llvm-commits, kzhuravl

Differential Revision: http://reviews.llvm.org/D21443

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273066 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:38:08 +00:00
Chris Bieneman
4aa4497a7d [obj2yaml] [yaml2obj] Support for MachO nlist and string table
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 22:54:06 +00:00
Reid Kleckner
fb1a91169a [COFF] Expose the PE debug data directory and dump it
This directory is used to find if there is a PDB associated with an
executable. I plan to use this functionality to teach llvm-symbolizer
whether it should use DIA or DWARF to symbolize a given DLL.

Reviewers: majnemer

Differential Revision: http://reviews.llvm.org/D20885

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 17:10:43 +00:00
Chris Bieneman
7e74f7a10f [obj2yaml][yaml2obj] Support for reading and dumping the MachO export trie
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271300 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31 17:26:36 +00:00
Chris Bieneman
7593509c1b [obj2yaml][yaml2obj] Support for MachO lazy bindings
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270920 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 21:29:39 +00:00
Chris Bieneman
429d7a4cff [obj2yaml][yaml2obj] Support for MachO weak bindings
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270911 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 20:50:05 +00:00
Chris Bieneman
7ad3d3b16b [obj2yaml][yaml2obj] Support for MachO bind opcodes
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270901 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 20:06:14 +00:00
Chris Bieneman
4877ca745f [obj2yaml] [yaml2obj] MachO support for rebase opcodes
This is the first bit of support for MachO __LINKEDIT segment data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270724 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 17:09:07 +00:00
Chris Bieneman
28b72d65ff [MachOYAML] Removing duplicated field from LC_UUID YAML
The uuid_command was duplicating the load_command.cmdsize field. This removes the duplicate from the YAML mapping and from the test cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270248 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 18:36:52 +00:00
Chris Bieneman
09166ea25b [obj2yaml] [yaml2obj] Support for MachO Load Command data
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:54:43 +00:00
Chris Bieneman
ac5b9174b6 Revert "[obj2yaml] [yaml2obj] Support for MachO Load Command data"
This reverts commit r270115.

This failed on several builders using GCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270121 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:48:54 +00:00
Chris Bieneman
dadbde9f38 [obj2yaml] [yaml2obj] Support for MachO Load Command data
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270115 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 20:40:03 +00:00
Chris Bieneman
7ec0ea16b7 Re-apply: [obj2yaml] [yaml2obj] Support MachO section and section_64
This re-applies r269845, r269846, and r269850 with an included fix for a crash reported by zturner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18 16:17:23 +00:00
Zachary Turner
8e5ffc9803 Revert "[obj2yaml] [yaml2obj] Support MachO section and section_64
structs"

This reverts commits r269845, r269846, and r269850 as they
introduce a crash in obj2yaml when trying to do a roundtrip.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269865 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 23:38:22 +00:00
Chris Bieneman
20b603a8a3 [obj2yaml][yaml2obj] Fixing dyld_info_command mappings
Apparently I mucked up the mappings here, which was causing some binary differences in round tripping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269846 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 21:33:59 +00:00
Chris Bieneman
b04144c7d6 [obj2yaml] [yaml2obj] Support MachO section and section_64 structs
This patch adds round trip support for MachO section structs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269845 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 21:31:02 +00:00
Chris Bieneman
0865cea8c3 Reapply r269782 "[obj2yaml] [yaml2obj] Support for MachO load command structures""
This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 19:44:06 +00:00
Chris Bieneman
923a9ba5c6 Revert "[obj2yaml] [yaml2obj] Support for MachO load command structures"
This reverts commit r269782 because it broke bots with -fpermissive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269785 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:13:50 +00:00
Chris Bieneman
4a038a7aac [obj2yaml] [yaml2obj] Support for MachO load command structures
This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269782 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17 17:03:28 +00:00
Chris Bieneman
062cef56d2 [obj2yaml] [yaml2obj] Basic support for MachO::load_command
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269442 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 17:41:41 +00:00
Chris Bieneman
d6f6aaf5e7 [yaml2macho] Handle mach_header_64 reserved field
I've added the reserved field as an "optional" in YAML, but I've added asserts in the yaml2macho code to enforce that the field is present in mach_header_64, but not in mach_header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269320 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 18:21:09 +00:00
Chris Bieneman
8413a15520 [ObjectYAML] filetype is a required field in MachO headers
Not sure how I managed to copy-pasta this wrong, but I did.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269317 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 17:53:01 +00:00
Chris Bieneman
dfa9a6bd95 [obj2yaml] Include all mach_header fields in yaml
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269313 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 17:44:43 +00:00
Chris Bieneman
7455ed8edf [ObjectYAML] Support Thin MachO headers to YAML
This patch adds support to ObjectYAML for serializing mach_header structs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269303 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 16:04:16 +00:00
Jacques Pienaar
cf0b01d7ec [lanai] Add Lanai backend.
Add the Lanai backend to lib/Target.

General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend" (http://lists.llvm.org/pipermail/llvm-dev/2016-February/095118.html).

Differential Revision: http://reviews.llvm.org/D17011



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264578 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28 13:09:54 +00:00
David Majnemer
5b6b93117d Forgot to commit this with r263692
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263721 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-17 16:55:11 +00:00
Valery Pykhtin
4915c55094 [AMDGPU] add AMDGPU target support to ELFObjectFile.h header
Differential Revision: http://reviews.llvm.org/D17144

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263026 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-09 17:08:19 +00:00
Rafael Espindola
b2d0b15d68 Add LLVMBuild for ObjectYAML.
Should fix the DBUILD_SHARED_LIBS bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262396 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 21:29:33 +00:00
Rafael Espindola
18903ff9fb Move ObjectYAML code to a new library.
It is only ever used by obj2yaml and yaml2obj. No point in linking it
everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262368 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-01 19:15:06 +00:00