2016-05-12 00:07:48 +02:00
|
|
|
//===- yaml2macho - Convert YAML to a Mach object file --------------------===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-05-12 00:07:48 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
2018-05-01 17:54:18 +02:00
|
|
|
/// The Mach component of yaml2obj.
|
2016-05-12 00:07:48 +02:00
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-07 05:48:56 +02:00
|
|
|
#include "llvm/BinaryFormat/MachO.h"
|
2017-01-12 22:35:21 +01:00
|
|
|
#include "llvm/ObjectYAML/DWARFEmitter.h"
|
2017-06-07 05:48:56 +02:00
|
|
|
#include "llvm/ObjectYAML/ObjectYAML.h"
|
[yaml2obj] Move core yaml2obj code into lib and include for use in unit tests
Reviewers: jhenderson, rupprecht, MaskRay, grimar, labath
Reviewed By: rupprecht
Subscribers: gribozavr, mgrang, seiya, mgorny, sbc100, hiraditya, aheejin, jakehehrlich, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65255
llvm-svn: 368119
2019-08-07 04:44:49 +02:00
|
|
|
#include "llvm/ObjectYAML/yaml2obj.h"
|
2020-05-27 10:59:45 +02:00
|
|
|
#include "llvm/Support/Errc.h"
|
|
|
|
#include "llvm/Support/Error.h"
|
2016-05-25 19:09:07 +02:00
|
|
|
#include "llvm/Support/LEB128.h"
|
2016-05-12 19:44:48 +02:00
|
|
|
#include "llvm/Support/YAMLTraits.h"
|
2016-05-12 00:07:48 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
2016-05-25 19:09:07 +02:00
|
|
|
#include "llvm/Support/Format.h"
|
|
|
|
|
2016-05-12 00:07:48 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
2016-05-12 19:44:48 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class MachOWriter {
|
|
|
|
public:
|
2020-08-03 10:14:47 +02:00
|
|
|
MachOWriter(MachOYAML::Object &Obj) : Obj(Obj), fileStart(0) {
|
2016-05-12 19:44:48 +02:00
|
|
|
is64Bit = Obj.Header.magic == MachO::MH_MAGIC_64 ||
|
|
|
|
Obj.Header.magic == MachO::MH_CIGAM_64;
|
2016-06-06 23:18:43 +02:00
|
|
|
memset(reinterpret_cast<void *>(&Header), 0, sizeof(MachO::mach_header_64));
|
2016-05-12 19:44:48 +02:00
|
|
|
}
|
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
Error writeMachO(raw_ostream &OS);
|
2016-05-12 19:44:48 +02:00
|
|
|
|
|
|
|
private:
|
2019-09-13 18:00:16 +02:00
|
|
|
void writeHeader(raw_ostream &OS);
|
|
|
|
void writeLoadCommands(raw_ostream &OS);
|
2020-05-27 10:59:45 +02:00
|
|
|
Error writeSectionData(raw_ostream &OS);
|
2020-04-22 20:50:55 +02:00
|
|
|
void writeRelocations(raw_ostream &OS);
|
2019-09-13 18:00:16 +02:00
|
|
|
void writeLinkEditData(raw_ostream &OS);
|
2016-12-22 22:58:03 +01:00
|
|
|
|
2016-06-03 18:58:05 +02:00
|
|
|
void writeBindOpcodes(raw_ostream &OS,
|
2016-05-26 22:50:05 +02:00
|
|
|
std::vector<MachOYAML::BindOpcode> &BindOpcodes);
|
2016-06-03 18:58:05 +02:00
|
|
|
// LinkEdit writers
|
2019-09-13 18:00:16 +02:00
|
|
|
void writeRebaseOpcodes(raw_ostream &OS);
|
|
|
|
void writeBasicBindOpcodes(raw_ostream &OS);
|
|
|
|
void writeWeakBindOpcodes(raw_ostream &OS);
|
|
|
|
void writeLazyBindOpcodes(raw_ostream &OS);
|
|
|
|
void writeNameList(raw_ostream &OS);
|
|
|
|
void writeStringTable(raw_ostream &OS);
|
|
|
|
void writeExportTrie(raw_ostream &OS);
|
2016-05-25 19:09:07 +02:00
|
|
|
|
2016-05-31 19:26:36 +02:00
|
|
|
void dumpExportEntry(raw_ostream &OS, MachOYAML::ExportEntry &Entry);
|
2016-05-25 19:09:07 +02:00
|
|
|
void ZeroToOffset(raw_ostream &OS, size_t offset);
|
2016-05-12 19:44:48 +02:00
|
|
|
|
2016-05-13 19:41:41 +02:00
|
|
|
MachOYAML::Object &Obj;
|
2016-05-12 19:44:48 +02:00
|
|
|
bool is64Bit;
|
2016-05-21 00:31:50 +02:00
|
|
|
uint64_t fileStart;
|
2016-06-06 23:18:43 +02:00
|
|
|
MachO::mach_header_64 Header;
|
2020-04-22 20:50:55 +02:00
|
|
|
|
|
|
|
// Old PPC Object Files didn't have __LINKEDIT segments, the data was just
|
|
|
|
// stuck at the end of the file.
|
|
|
|
bool FoundLinkEditSeg = false;
|
2016-05-12 19:44:48 +02:00
|
|
|
};
|
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
Error MachOWriter::writeMachO(raw_ostream &OS) {
|
2016-05-21 00:31:50 +02:00
|
|
|
fileStart = OS.tell();
|
2019-09-13 18:00:16 +02:00
|
|
|
writeHeader(OS);
|
|
|
|
writeLoadCommands(OS);
|
2020-05-27 10:59:45 +02:00
|
|
|
if (Error Err = writeSectionData(OS))
|
|
|
|
return Err;
|
2020-04-22 20:50:55 +02:00
|
|
|
writeRelocations(OS);
|
|
|
|
if (!FoundLinkEditSeg)
|
|
|
|
writeLinkEditData(OS);
|
2020-05-27 10:59:45 +02:00
|
|
|
return Error::success();
|
2016-05-12 19:44:48 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeHeader(raw_ostream &OS) {
|
2016-05-12 19:44:48 +02:00
|
|
|
Header.magic = Obj.Header.magic;
|
|
|
|
Header.cputype = Obj.Header.cputype;
|
|
|
|
Header.cpusubtype = Obj.Header.cpusubtype;
|
|
|
|
Header.filetype = Obj.Header.filetype;
|
|
|
|
Header.ncmds = Obj.Header.ncmds;
|
|
|
|
Header.sizeofcmds = Obj.Header.sizeofcmds;
|
|
|
|
Header.flags = Obj.Header.flags;
|
2016-06-06 23:18:43 +02:00
|
|
|
Header.reserved = Obj.Header.reserved;
|
2016-05-12 19:44:48 +02:00
|
|
|
|
2016-12-22 22:58:03 +01:00
|
|
|
if (Obj.IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(Header);
|
|
|
|
|
2016-06-06 23:18:43 +02:00
|
|
|
auto header_size =
|
|
|
|
is64Bit ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header);
|
|
|
|
OS.write((const char *)&Header, header_size);
|
2016-05-12 19:44:48 +02:00
|
|
|
}
|
|
|
|
|
2016-05-18 18:17:23 +02:00
|
|
|
template <typename SectionType>
|
|
|
|
SectionType constructSection(MachOYAML::Section Sec) {
|
|
|
|
SectionType TempSec;
|
|
|
|
memcpy(reinterpret_cast<void *>(&TempSec.sectname[0]), &Sec.sectname[0], 16);
|
|
|
|
memcpy(reinterpret_cast<void *>(&TempSec.segname[0]), &Sec.segname[0], 16);
|
|
|
|
TempSec.addr = Sec.addr;
|
|
|
|
TempSec.size = Sec.size;
|
|
|
|
TempSec.offset = Sec.offset;
|
|
|
|
TempSec.align = Sec.align;
|
|
|
|
TempSec.reloff = Sec.reloff;
|
|
|
|
TempSec.nreloc = Sec.nreloc;
|
|
|
|
TempSec.flags = Sec.flags;
|
|
|
|
TempSec.reserved1 = Sec.reserved1;
|
|
|
|
TempSec.reserved2 = Sec.reserved2;
|
|
|
|
return TempSec;
|
|
|
|
}
|
|
|
|
|
2016-05-19 22:54:43 +02:00
|
|
|
template <typename StructType>
|
2016-12-22 22:58:03 +01:00
|
|
|
size_t writeLoadCommandData(MachOYAML::LoadCommand &LC, raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-05-19 22:54:43 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
size_t writeLoadCommandData<MachO::segment_command>(MachOYAML::LoadCommand &LC,
|
2016-12-22 22:58:03 +01:00
|
|
|
raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-05-19 22:54:43 +02:00
|
|
|
size_t BytesWritten = 0;
|
2016-05-27 14:30:51 +02:00
|
|
|
for (const auto &Sec : LC.Sections) {
|
2016-05-19 22:54:43 +02:00
|
|
|
auto TempSec = constructSection<MachO::section>(Sec);
|
2016-12-22 22:58:03 +01:00
|
|
|
if (IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(TempSec);
|
2016-05-19 22:54:43 +02:00
|
|
|
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
|
|
|
sizeof(MachO::section));
|
|
|
|
BytesWritten += sizeof(MachO::section);
|
|
|
|
}
|
|
|
|
return BytesWritten;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2016-12-22 22:58:03 +01:00
|
|
|
size_t writeLoadCommandData<MachO::segment_command_64>(
|
|
|
|
MachOYAML::LoadCommand &LC, raw_ostream &OS, bool IsLittleEndian) {
|
2016-05-19 22:54:43 +02:00
|
|
|
size_t BytesWritten = 0;
|
2016-05-27 14:30:51 +02:00
|
|
|
for (const auto &Sec : LC.Sections) {
|
2016-05-19 22:54:43 +02:00
|
|
|
auto TempSec = constructSection<MachO::section_64>(Sec);
|
|
|
|
TempSec.reserved3 = Sec.reserved3;
|
2016-12-22 22:58:03 +01:00
|
|
|
if (IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(TempSec);
|
2016-05-19 22:54:43 +02:00
|
|
|
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
|
|
|
sizeof(MachO::section_64));
|
|
|
|
BytesWritten += sizeof(MachO::section_64);
|
|
|
|
}
|
|
|
|
return BytesWritten;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t writePayloadString(MachOYAML::LoadCommand &LC, raw_ostream &OS) {
|
|
|
|
size_t BytesWritten = 0;
|
2021-07-26 18:04:51 +02:00
|
|
|
if (!LC.Content.empty()) {
|
|
|
|
OS.write(LC.Content.c_str(), LC.Content.length());
|
|
|
|
BytesWritten = LC.Content.length();
|
2016-05-19 22:54:43 +02:00
|
|
|
}
|
|
|
|
return BytesWritten;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
size_t writeLoadCommandData<MachO::dylib_command>(MachOYAML::LoadCommand &LC,
|
2016-12-22 22:58:03 +01:00
|
|
|
raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-05-19 22:54:43 +02:00
|
|
|
return writePayloadString(LC, OS);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
size_t writeLoadCommandData<MachO::dylinker_command>(MachOYAML::LoadCommand &LC,
|
2016-12-22 22:58:03 +01:00
|
|
|
raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-05-19 22:54:43 +02:00
|
|
|
return writePayloadString(LC, OS);
|
|
|
|
}
|
|
|
|
|
2016-05-31 19:26:36 +02:00
|
|
|
template <>
|
|
|
|
size_t writeLoadCommandData<MachO::rpath_command>(MachOYAML::LoadCommand &LC,
|
2016-12-22 22:58:03 +01:00
|
|
|
raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-05-31 19:26:36 +02:00
|
|
|
return writePayloadString(LC, OS);
|
|
|
|
}
|
|
|
|
|
2017-01-23 21:07:55 +01:00
|
|
|
template <>
|
|
|
|
size_t writeLoadCommandData<MachO::build_version_command>(
|
|
|
|
MachOYAML::LoadCommand &LC, raw_ostream &OS, bool IsLittleEndian) {
|
|
|
|
size_t BytesWritten = 0;
|
|
|
|
for (const auto &T : LC.Tools) {
|
|
|
|
struct MachO::build_tool_version tool = T;
|
|
|
|
if (IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(tool);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&tool),
|
|
|
|
sizeof(MachO::build_tool_version));
|
|
|
|
BytesWritten += sizeof(MachO::build_tool_version);
|
|
|
|
}
|
|
|
|
return BytesWritten;
|
|
|
|
}
|
|
|
|
|
2016-05-21 00:31:50 +02:00
|
|
|
void ZeroFillBytes(raw_ostream &OS, size_t Size) {
|
2021-01-18 19:16:33 +01:00
|
|
|
std::vector<uint8_t> FillData(Size, 0);
|
2016-05-21 00:31:50 +02:00
|
|
|
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fill(raw_ostream &OS, size_t Size, uint32_t Data) {
|
2021-01-18 19:16:33 +01:00
|
|
|
std::vector<uint32_t> FillData((Size / 4) + 1, Data);
|
2016-05-21 00:31:50 +02:00
|
|
|
OS.write(reinterpret_cast<char *>(FillData.data()), Size);
|
|
|
|
}
|
|
|
|
|
2016-05-25 19:09:07 +02:00
|
|
|
void MachOWriter::ZeroToOffset(raw_ostream &OS, size_t Offset) {
|
|
|
|
auto currOffset = OS.tell() - fileStart;
|
|
|
|
if (currOffset < Offset)
|
|
|
|
ZeroFillBytes(OS, Offset - currOffset);
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeLoadCommands(raw_ostream &OS) {
|
2016-05-13 19:41:41 +02:00
|
|
|
for (auto &LC : Obj.LoadCommands) {
|
2016-05-17 21:44:06 +02:00
|
|
|
size_t BytesWritten = 0;
|
2016-12-22 22:58:03 +01:00
|
|
|
llvm::MachO::macho_load_command Data = LC.Data;
|
|
|
|
|
2016-05-17 21:44:06 +02:00
|
|
|
#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
|
|
|
|
case MachO::LCName: \
|
2016-12-22 22:58:03 +01:00
|
|
|
if (Obj.IsLittleEndian != sys::IsLittleEndianHost) \
|
|
|
|
MachO::swapStruct(Data.LCStruct##_data); \
|
|
|
|
OS.write(reinterpret_cast<const char *>(&(Data.LCStruct##_data)), \
|
2016-05-17 21:44:06 +02:00
|
|
|
sizeof(MachO::LCStruct)); \
|
|
|
|
BytesWritten = sizeof(MachO::LCStruct); \
|
2016-12-22 22:58:03 +01:00
|
|
|
BytesWritten += \
|
|
|
|
writeLoadCommandData<MachO::LCStruct>(LC, OS, Obj.IsLittleEndian); \
|
2016-05-17 21:44:06 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
switch (LC.Data.load_command_data.cmd) {
|
|
|
|
default:
|
2016-12-22 22:58:03 +01:00
|
|
|
if (Obj.IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(Data.load_command_data);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&(Data.load_command_data)),
|
2016-05-17 21:44:06 +02:00
|
|
|
sizeof(MachO::load_command));
|
|
|
|
BytesWritten = sizeof(MachO::load_command);
|
2016-12-22 22:58:03 +01:00
|
|
|
BytesWritten +=
|
|
|
|
writeLoadCommandData<MachO::load_command>(LC, OS, Obj.IsLittleEndian);
|
2016-05-17 21:44:06 +02:00
|
|
|
break;
|
2017-06-07 05:48:56 +02:00
|
|
|
#include "llvm/BinaryFormat/MachO.def"
|
2016-05-17 21:44:06 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 22:54:43 +02:00
|
|
|
if (LC.PayloadBytes.size() > 0) {
|
|
|
|
OS.write(reinterpret_cast<const char *>(LC.PayloadBytes.data()),
|
|
|
|
LC.PayloadBytes.size());
|
|
|
|
BytesWritten += LC.PayloadBytes.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LC.ZeroPadBytes > 0) {
|
2016-05-21 00:31:50 +02:00
|
|
|
ZeroFillBytes(OS, LC.ZeroPadBytes);
|
2016-05-19 22:54:43 +02:00
|
|
|
BytesWritten += LC.ZeroPadBytes;
|
2016-05-18 18:17:23 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 01:26:31 +02:00
|
|
|
// Fill remaining bytes with 0. This will only get hit in partially
|
|
|
|
// specified test cases.
|
2016-05-19 22:54:43 +02:00
|
|
|
auto BytesRemaining = LC.Data.load_command_data.cmdsize - BytesWritten;
|
2016-05-17 21:44:06 +02:00
|
|
|
if (BytesRemaining > 0) {
|
2016-05-21 00:31:50 +02:00
|
|
|
ZeroFillBytes(OS, BytesRemaining);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
Error MachOWriter::writeSectionData(raw_ostream &OS) {
|
2016-05-21 00:31:50 +02:00
|
|
|
for (auto &LC : Obj.LoadCommands) {
|
|
|
|
switch (LC.Data.load_command_data.cmd) {
|
|
|
|
case MachO::LC_SEGMENT:
|
|
|
|
case MachO::LC_SEGMENT_64:
|
|
|
|
uint64_t segOff = is64Bit ? LC.Data.segment_command_64_data.fileoff
|
|
|
|
: LC.Data.segment_command_data.fileoff;
|
[yaml2obj] Move core yaml2obj code into lib and include for use in unit tests
Reviewers: jhenderson, rupprecht, MaskRay, grimar, labath
Reviewed By: rupprecht
Subscribers: gribozavr, mgrang, seiya, mgorny, sbc100, hiraditya, aheejin, jakehehrlich, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65255
llvm-svn: 368119
2019-08-07 04:44:49 +02:00
|
|
|
if (0 ==
|
|
|
|
strncmp(&LC.Data.segment_command_data.segname[0], "__LINKEDIT", 16)) {
|
2016-12-22 22:58:03 +01:00
|
|
|
FoundLinkEditSeg = true;
|
2019-09-13 18:00:16 +02:00
|
|
|
writeLinkEditData(OS);
|
2016-12-22 22:58:03 +01:00
|
|
|
}
|
|
|
|
for (auto &Sec : LC.Sections) {
|
|
|
|
ZeroToOffset(OS, Sec.offset);
|
2016-05-21 00:31:50 +02:00
|
|
|
// Zero Fill any data between the end of the last thing we wrote and the
|
|
|
|
// start of this section.
|
2020-05-27 10:59:45 +02:00
|
|
|
if (OS.tell() - fileStart > Sec.offset && Sec.offset != (uint32_t)0)
|
|
|
|
return createStringError(
|
|
|
|
errc::invalid_argument,
|
|
|
|
"wrote too much data somewhere, section offsets don't line up");
|
2019-06-17 04:07:20 +02:00
|
|
|
|
2020-09-04 16:41:25 +02:00
|
|
|
StringRef SectName(Sec.sectname,
|
|
|
|
strnlen(Sec.sectname, sizeof(Sec.sectname)));
|
|
|
|
// If the section's content is specified in the 'DWARF' entry, we will
|
|
|
|
// emit it regardless of the section's segname.
|
|
|
|
if (Obj.DWARF.getNonEmptySectionNames().count(SectName.substr(2))) {
|
|
|
|
if (Sec.content)
|
|
|
|
return createStringError(errc::invalid_argument,
|
|
|
|
"cannot specify section '" + SectName +
|
|
|
|
"' contents in the 'DWARF' entry and "
|
|
|
|
"the 'content' at the same time");
|
|
|
|
auto EmitFunc = DWARFYAML::getDWARFEmitterByName(SectName.substr(2));
|
|
|
|
if (Error Err = EmitFunc(OS, Obj.DWARF))
|
|
|
|
return Err;
|
2019-06-17 04:07:20 +02:00
|
|
|
continue;
|
2016-05-25 19:09:07 +02:00
|
|
|
}
|
2019-06-17 04:07:20 +02:00
|
|
|
|
|
|
|
// Skip if it's a virtual section.
|
2019-08-20 10:49:07 +02:00
|
|
|
if (MachO::isVirtualSection(Sec.flags & MachO::SECTION_TYPE))
|
2019-06-17 04:07:20 +02:00
|
|
|
continue;
|
|
|
|
|
2019-08-20 10:49:07 +02:00
|
|
|
if (Sec.content) {
|
|
|
|
yaml::BinaryRef Content = *Sec.content;
|
|
|
|
Content.writeAsBinary(OS);
|
|
|
|
ZeroFillBytes(OS, Sec.size - Content.binary_size());
|
|
|
|
} else {
|
|
|
|
// Fill section data with 0xDEADBEEF.
|
|
|
|
Fill(OS, Sec.size, 0xDEADBEEFu);
|
|
|
|
}
|
2016-05-21 00:31:50 +02:00
|
|
|
}
|
|
|
|
uint64_t segSize = is64Bit ? LC.Data.segment_command_64_data.filesize
|
|
|
|
: LC.Data.segment_command_data.filesize;
|
2016-05-25 19:09:07 +02:00
|
|
|
ZeroToOffset(OS, segOff + segSize);
|
2016-05-21 00:31:50 +02:00
|
|
|
break;
|
2016-05-13 19:41:41 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 10:59:45 +02:00
|
|
|
|
|
|
|
return Error::success();
|
2020-04-22 20:50:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The implementation of makeRelocationInfo and makeScatteredRelocationInfo is
|
|
|
|
// consistent with how libObject parses MachO binary files. For the reference
|
|
|
|
// see getStruct, getRelocation, getPlainRelocationPCRel,
|
|
|
|
// getPlainRelocationLength and related methods in MachOObjectFile.cpp
|
|
|
|
static MachO::any_relocation_info
|
|
|
|
makeRelocationInfo(const MachOYAML::Relocation &R, bool IsLE) {
|
|
|
|
assert(!R.is_scattered && "non-scattered relocation expected");
|
|
|
|
MachO::any_relocation_info MRE;
|
|
|
|
MRE.r_word0 = R.address;
|
|
|
|
if (IsLE)
|
|
|
|
MRE.r_word1 = ((unsigned)R.symbolnum << 0) | ((unsigned)R.is_pcrel << 24) |
|
|
|
|
((unsigned)R.length << 25) | ((unsigned)R.is_extern << 27) |
|
|
|
|
((unsigned)R.type << 28);
|
|
|
|
else
|
|
|
|
MRE.r_word1 = ((unsigned)R.symbolnum << 8) | ((unsigned)R.is_pcrel << 7) |
|
|
|
|
((unsigned)R.length << 5) | ((unsigned)R.is_extern << 4) |
|
|
|
|
((unsigned)R.type << 0);
|
|
|
|
return MRE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MachO::any_relocation_info
|
|
|
|
makeScatteredRelocationInfo(const MachOYAML::Relocation &R) {
|
|
|
|
assert(R.is_scattered && "scattered relocation expected");
|
|
|
|
MachO::any_relocation_info MRE;
|
|
|
|
MRE.r_word0 = (((unsigned)R.address << 0) | ((unsigned)R.type << 24) |
|
|
|
|
((unsigned)R.length << 28) | ((unsigned)R.is_pcrel << 30) |
|
|
|
|
MachO::R_SCATTERED);
|
|
|
|
MRE.r_word1 = R.value;
|
|
|
|
return MRE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachOWriter::writeRelocations(raw_ostream &OS) {
|
|
|
|
for (const MachOYAML::LoadCommand &LC : Obj.LoadCommands) {
|
|
|
|
switch (LC.Data.load_command_data.cmd) {
|
|
|
|
case MachO::LC_SEGMENT:
|
|
|
|
case MachO::LC_SEGMENT_64:
|
|
|
|
for (const MachOYAML::Section &Sec : LC.Sections) {
|
|
|
|
if (Sec.relocations.empty())
|
|
|
|
continue;
|
|
|
|
ZeroToOffset(OS, Sec.reloff);
|
|
|
|
for (const MachOYAML::Relocation &R : Sec.relocations) {
|
|
|
|
MachO::any_relocation_info MRE =
|
|
|
|
R.is_scattered ? makeScatteredRelocationInfo(R)
|
|
|
|
: makeRelocationInfo(R, Obj.IsLittleEndian);
|
|
|
|
if (Obj.IsLittleEndian != sys::IsLittleEndianHost)
|
|
|
|
MachO::swapStruct(MRE);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&MRE),
|
|
|
|
sizeof(MachO::any_relocation_info));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-13 19:41:41 +02:00
|
|
|
}
|
|
|
|
|
2016-05-26 22:50:05 +02:00
|
|
|
void MachOWriter::writeBindOpcodes(
|
2016-06-03 18:58:05 +02:00
|
|
|
raw_ostream &OS, std::vector<MachOYAML::BindOpcode> &BindOpcodes) {
|
2016-05-26 22:50:05 +02:00
|
|
|
|
|
|
|
for (auto Opcode : BindOpcodes) {
|
|
|
|
uint8_t OpByte = Opcode.Opcode | Opcode.Imm;
|
|
|
|
OS.write(reinterpret_cast<char *>(&OpByte), 1);
|
|
|
|
for (auto Data : Opcode.ULEBExtraData) {
|
|
|
|
encodeULEB128(Data, OS);
|
|
|
|
}
|
|
|
|
for (auto Data : Opcode.SLEBExtraData) {
|
|
|
|
encodeSLEB128(Data, OS);
|
|
|
|
}
|
|
|
|
if (!Opcode.Symbol.empty()) {
|
|
|
|
OS.write(Opcode.Symbol.data(), Opcode.Symbol.size());
|
2016-05-31 19:26:36 +02:00
|
|
|
OS.write('\0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 00:54:06 +02:00
|
|
|
void MachOWriter::dumpExportEntry(raw_ostream &OS,
|
|
|
|
MachOYAML::ExportEntry &Entry) {
|
2016-05-31 19:26:36 +02:00
|
|
|
encodeSLEB128(Entry.TerminalSize, OS);
|
|
|
|
if (Entry.TerminalSize > 0) {
|
|
|
|
encodeSLEB128(Entry.Flags, OS);
|
2016-06-03 00:54:06 +02:00
|
|
|
if (Entry.Flags & MachO::EXPORT_SYMBOL_FLAGS_REEXPORT) {
|
2016-05-31 19:26:36 +02:00
|
|
|
encodeSLEB128(Entry.Other, OS);
|
|
|
|
OS << Entry.ImportName;
|
|
|
|
OS.write('\0');
|
2016-06-03 00:54:06 +02:00
|
|
|
} else {
|
2016-05-31 19:26:36 +02:00
|
|
|
encodeSLEB128(Entry.Address, OS);
|
|
|
|
if (Entry.Flags & MachO::EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER)
|
|
|
|
encodeSLEB128(Entry.Other, OS);
|
2016-05-26 22:50:05 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-31 19:26:36 +02:00
|
|
|
OS.write(static_cast<uint8_t>(Entry.Children.size()));
|
2016-06-03 00:54:06 +02:00
|
|
|
for (auto EE : Entry.Children) {
|
2016-05-31 19:26:36 +02:00
|
|
|
OS << EE.Name;
|
|
|
|
OS.write('\0');
|
|
|
|
encodeSLEB128(EE.NodeOffset, OS);
|
|
|
|
}
|
|
|
|
for (auto EE : Entry.Children)
|
|
|
|
dumpExportEntry(OS, EE);
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeExportTrie(raw_ostream &OS) {
|
2016-05-31 19:26:36 +02:00
|
|
|
dumpExportEntry(OS, Obj.LinkEdit.ExportTrie);
|
2016-05-26 22:50:05 +02:00
|
|
|
}
|
|
|
|
|
2016-06-03 00:54:06 +02:00
|
|
|
template <typename NListType>
|
2016-12-22 22:58:03 +01:00
|
|
|
void writeNListEntry(MachOYAML::NListEntry &NLE, raw_ostream &OS,
|
|
|
|
bool IsLittleEndian) {
|
2016-06-03 00:54:06 +02:00
|
|
|
NListType ListEntry;
|
|
|
|
ListEntry.n_strx = NLE.n_strx;
|
|
|
|
ListEntry.n_type = NLE.n_type;
|
|
|
|
ListEntry.n_sect = NLE.n_sect;
|
|
|
|
ListEntry.n_desc = NLE.n_desc;
|
|
|
|
ListEntry.n_value = NLE.n_value;
|
2016-12-22 22:58:03 +01:00
|
|
|
|
2016-12-22 23:16:04 +01:00
|
|
|
if (IsLittleEndian != sys::IsLittleEndianHost)
|
2016-12-22 22:58:03 +01:00
|
|
|
MachO::swapStruct(ListEntry);
|
2016-06-03 00:54:06 +02:00
|
|
|
OS.write(reinterpret_cast<const char *>(&ListEntry), sizeof(NListType));
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeLinkEditData(raw_ostream &OS) {
|
|
|
|
typedef void (MachOWriter::*writeHandler)(raw_ostream &);
|
2016-06-03 18:58:05 +02:00
|
|
|
typedef std::pair<uint64_t, writeHandler> writeOperation;
|
|
|
|
std::vector<writeOperation> WriteQueue;
|
|
|
|
|
2016-05-25 19:09:07 +02:00
|
|
|
MachO::dyld_info_command *DyldInfoOnlyCmd = 0;
|
|
|
|
MachO::symtab_command *SymtabCmd = 0;
|
|
|
|
for (auto &LC : Obj.LoadCommands) {
|
|
|
|
switch (LC.Data.load_command_data.cmd) {
|
|
|
|
case MachO::LC_SYMTAB:
|
|
|
|
SymtabCmd = &LC.Data.symtab_command_data;
|
2016-06-03 18:58:05 +02:00
|
|
|
WriteQueue.push_back(
|
|
|
|
std::make_pair(SymtabCmd->symoff, &MachOWriter::writeNameList));
|
|
|
|
WriteQueue.push_back(
|
|
|
|
std::make_pair(SymtabCmd->stroff, &MachOWriter::writeStringTable));
|
2016-05-25 19:09:07 +02:00
|
|
|
break;
|
|
|
|
case MachO::LC_DYLD_INFO_ONLY:
|
|
|
|
DyldInfoOnlyCmd = &LC.Data.dyld_info_command_data;
|
2016-06-03 18:58:05 +02:00
|
|
|
WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->rebase_off,
|
|
|
|
&MachOWriter::writeRebaseOpcodes));
|
|
|
|
WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->bind_off,
|
|
|
|
&MachOWriter::writeBasicBindOpcodes));
|
|
|
|
WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->weak_bind_off,
|
|
|
|
&MachOWriter::writeWeakBindOpcodes));
|
|
|
|
WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->lazy_bind_off,
|
|
|
|
&MachOWriter::writeLazyBindOpcodes));
|
|
|
|
WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->export_off,
|
|
|
|
&MachOWriter::writeExportTrie));
|
2016-05-25 19:09:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.
Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb
Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits
Differential Revision: https://reviews.llvm.org/D52573
llvm-svn: 343163
2018-09-27 04:13:45 +02:00
|
|
|
llvm::sort(WriteQueue, [](const writeOperation &a, const writeOperation &b) {
|
|
|
|
return a.first < b.first;
|
|
|
|
});
|
2016-06-03 18:58:05 +02:00
|
|
|
|
|
|
|
for (auto writeOp : WriteQueue) {
|
|
|
|
ZeroToOffset(OS, writeOp.first);
|
2019-09-13 18:00:16 +02:00
|
|
|
(this->*writeOp.second)(OS);
|
2016-06-03 18:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeRebaseOpcodes(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
MachOYAML::LinkEditData &LinkEdit = Obj.LinkEdit;
|
2016-05-25 19:09:07 +02:00
|
|
|
|
|
|
|
for (auto Opcode : LinkEdit.RebaseOpcodes) {
|
|
|
|
uint8_t OpByte = Opcode.Opcode | Opcode.Imm;
|
|
|
|
OS.write(reinterpret_cast<char *>(&OpByte), 1);
|
2019-09-13 18:00:16 +02:00
|
|
|
for (auto Data : Opcode.ExtraData)
|
2016-05-25 19:09:07 +02:00
|
|
|
encodeULEB128(Data, OS);
|
|
|
|
}
|
2016-06-03 18:58:05 +02:00
|
|
|
}
|
2016-05-25 19:09:07 +02:00
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeBasicBindOpcodes(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
writeBindOpcodes(OS, Obj.LinkEdit.BindOpcodes);
|
|
|
|
}
|
2016-05-26 22:06:14 +02:00
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeWeakBindOpcodes(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
writeBindOpcodes(OS, Obj.LinkEdit.WeakBindOpcodes);
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeLazyBindOpcodes(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
writeBindOpcodes(OS, Obj.LinkEdit.LazyBindOpcodes);
|
|
|
|
}
|
2016-05-31 19:26:36 +02:00
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeNameList(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
for (auto NLE : Obj.LinkEdit.NameList) {
|
2016-06-03 00:54:06 +02:00
|
|
|
if (is64Bit)
|
2016-12-22 22:58:03 +01:00
|
|
|
writeNListEntry<MachO::nlist_64>(NLE, OS, Obj.IsLittleEndian);
|
2016-06-03 00:54:06 +02:00
|
|
|
else
|
2016-12-22 22:58:03 +01:00
|
|
|
writeNListEntry<MachO::nlist>(NLE, OS, Obj.IsLittleEndian);
|
2016-06-03 00:54:06 +02:00
|
|
|
}
|
2016-06-03 18:58:05 +02:00
|
|
|
}
|
2016-06-03 00:54:06 +02:00
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void MachOWriter::writeStringTable(raw_ostream &OS) {
|
2016-06-03 18:58:05 +02:00
|
|
|
for (auto Str : Obj.LinkEdit.StringTable) {
|
2016-06-03 00:54:06 +02:00
|
|
|
OS.write(Str.data(), Str.size());
|
|
|
|
OS.write('\0');
|
|
|
|
}
|
2016-05-25 19:09:07 +02:00
|
|
|
}
|
|
|
|
|
2016-06-24 22:42:28 +02:00
|
|
|
class UniversalWriter {
|
|
|
|
public:
|
2016-06-27 21:53:53 +02:00
|
|
|
UniversalWriter(yaml::YamlObjectFile &ObjectFile)
|
|
|
|
: ObjectFile(ObjectFile), fileStart(0) {}
|
2016-06-24 22:42:28 +02:00
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
Error writeMachO(raw_ostream &OS);
|
2016-06-24 22:42:28 +02:00
|
|
|
|
|
|
|
private:
|
2019-09-13 18:00:16 +02:00
|
|
|
void writeFatHeader(raw_ostream &OS);
|
|
|
|
void writeFatArchs(raw_ostream &OS);
|
2016-06-24 22:42:28 +02:00
|
|
|
|
|
|
|
void ZeroToOffset(raw_ostream &OS, size_t offset);
|
|
|
|
|
2016-06-27 21:53:53 +02:00
|
|
|
yaml::YamlObjectFile &ObjectFile;
|
2016-06-24 22:42:28 +02:00
|
|
|
uint64_t fileStart;
|
|
|
|
};
|
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
Error UniversalWriter::writeMachO(raw_ostream &OS) {
|
2016-06-24 22:42:28 +02:00
|
|
|
fileStart = OS.tell();
|
2016-06-27 21:53:53 +02:00
|
|
|
if (ObjectFile.MachO) {
|
|
|
|
MachOWriter Writer(*ObjectFile.MachO);
|
2020-05-27 10:59:45 +02:00
|
|
|
return Writer.writeMachO(OS);
|
2016-06-24 22:42:28 +02:00
|
|
|
}
|
2019-09-13 18:00:16 +02:00
|
|
|
|
|
|
|
writeFatHeader(OS);
|
|
|
|
writeFatArchs(OS);
|
|
|
|
|
2016-06-27 21:53:53 +02:00
|
|
|
auto &FatFile = *ObjectFile.FatMachO;
|
2020-05-27 10:59:45 +02:00
|
|
|
if (FatFile.FatArchs.size() < FatFile.Slices.size())
|
|
|
|
return createStringError(
|
|
|
|
errc::invalid_argument,
|
|
|
|
"cannot write 'Slices' if not described in 'FatArches'");
|
|
|
|
|
2016-06-24 22:42:28 +02:00
|
|
|
for (size_t i = 0; i < FatFile.Slices.size(); i++) {
|
|
|
|
ZeroToOffset(OS, FatFile.FatArchs[i].offset);
|
|
|
|
MachOWriter Writer(FatFile.Slices[i]);
|
2020-05-27 10:59:45 +02:00
|
|
|
if (Error Err = Writer.writeMachO(OS))
|
|
|
|
return Err;
|
2019-09-13 18:00:16 +02:00
|
|
|
|
2016-06-24 22:42:28 +02:00
|
|
|
auto SliceEnd = FatFile.FatArchs[i].offset + FatFile.FatArchs[i].size;
|
|
|
|
ZeroToOffset(OS, SliceEnd);
|
|
|
|
}
|
2020-05-27 10:59:45 +02:00
|
|
|
|
|
|
|
return Error::success();
|
2016-06-24 22:42:28 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void UniversalWriter::writeFatHeader(raw_ostream &OS) {
|
2016-06-27 21:53:53 +02:00
|
|
|
auto &FatFile = *ObjectFile.FatMachO;
|
2016-06-24 22:42:28 +02:00
|
|
|
MachO::fat_header header;
|
|
|
|
header.magic = FatFile.Header.magic;
|
|
|
|
header.nfat_arch = FatFile.Header.nfat_arch;
|
|
|
|
if (sys::IsLittleEndianHost)
|
|
|
|
swapStruct(header);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&header), sizeof(MachO::fat_header));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FatArchType>
|
|
|
|
FatArchType constructFatArch(MachOYAML::FatArch &Arch) {
|
|
|
|
FatArchType FatArch;
|
|
|
|
FatArch.cputype = Arch.cputype;
|
|
|
|
FatArch.cpusubtype = Arch.cpusubtype;
|
|
|
|
FatArch.offset = Arch.offset;
|
|
|
|
FatArch.size = Arch.size;
|
|
|
|
FatArch.align = Arch.align;
|
|
|
|
return FatArch;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename StructType>
|
|
|
|
void writeFatArch(MachOYAML::FatArch &LC, raw_ostream &OS) {}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void writeFatArch<MachO::fat_arch>(MachOYAML::FatArch &Arch, raw_ostream &OS) {
|
|
|
|
auto FatArch = constructFatArch<MachO::fat_arch>(Arch);
|
|
|
|
if (sys::IsLittleEndianHost)
|
|
|
|
swapStruct(FatArch);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&FatArch), sizeof(MachO::fat_arch));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void writeFatArch<MachO::fat_arch_64>(MachOYAML::FatArch &Arch,
|
|
|
|
raw_ostream &OS) {
|
|
|
|
auto FatArch = constructFatArch<MachO::fat_arch_64>(Arch);
|
|
|
|
FatArch.reserved = Arch.reserved;
|
|
|
|
if (sys::IsLittleEndianHost)
|
|
|
|
swapStruct(FatArch);
|
|
|
|
OS.write(reinterpret_cast<const char *>(&FatArch),
|
|
|
|
sizeof(MachO::fat_arch_64));
|
|
|
|
}
|
|
|
|
|
2019-09-13 18:00:16 +02:00
|
|
|
void UniversalWriter::writeFatArchs(raw_ostream &OS) {
|
2016-06-27 21:53:53 +02:00
|
|
|
auto &FatFile = *ObjectFile.FatMachO;
|
2016-06-24 22:42:28 +02:00
|
|
|
bool is64Bit = FatFile.Header.magic == MachO::FAT_MAGIC_64;
|
|
|
|
for (auto Arch : FatFile.FatArchs) {
|
|
|
|
if (is64Bit)
|
|
|
|
writeFatArch<MachO::fat_arch_64>(Arch, OS);
|
|
|
|
else
|
|
|
|
writeFatArch<MachO::fat_arch>(Arch, OS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UniversalWriter::ZeroToOffset(raw_ostream &OS, size_t Offset) {
|
|
|
|
auto currOffset = OS.tell() - fileStart;
|
|
|
|
if (currOffset < Offset)
|
|
|
|
ZeroFillBytes(OS, Offset - currOffset);
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:44:48 +02:00
|
|
|
} // end anonymous namespace
|
|
|
|
|
[yaml2obj] Move core yaml2obj code into lib and include for use in unit tests
Reviewers: jhenderson, rupprecht, MaskRay, grimar, labath
Reviewed By: rupprecht
Subscribers: gribozavr, mgrang, seiya, mgorny, sbc100, hiraditya, aheejin, jakehehrlich, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65255
llvm-svn: 368119
2019-08-07 04:44:49 +02:00
|
|
|
namespace llvm {
|
|
|
|
namespace yaml {
|
|
|
|
|
2020-05-27 10:59:45 +02:00
|
|
|
bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH) {
|
2016-06-24 22:42:28 +02:00
|
|
|
UniversalWriter Writer(Doc);
|
2020-05-27 10:59:45 +02:00
|
|
|
if (Error Err = Writer.writeMachO(Out)) {
|
|
|
|
handleAllErrors(std::move(Err),
|
|
|
|
[&](const ErrorInfoBase &Err) { EH(Err.message()); });
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-13 11:12:38 +02:00
|
|
|
return true;
|
2016-05-12 00:07:48 +02:00
|
|
|
}
|
[yaml2obj] Move core yaml2obj code into lib and include for use in unit tests
Reviewers: jhenderson, rupprecht, MaskRay, grimar, labath
Reviewed By: rupprecht
Subscribers: gribozavr, mgrang, seiya, mgorny, sbc100, hiraditya, aheejin, jakehehrlich, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65255
llvm-svn: 368119
2019-08-07 04:44:49 +02:00
|
|
|
|
|
|
|
} // namespace yaml
|
|
|
|
} // namespace llvm
|