summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/obj2yaml/macho2yaml.cpp54
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp32
2 files changed, 0 insertions, 86 deletions
diff --git a/llvm/tools/obj2yaml/macho2yaml.cpp b/llvm/tools/obj2yaml/macho2yaml.cpp
index 66244c30e40..cbf55ba35a5 100644
--- a/llvm/tools/obj2yaml/macho2yaml.cpp
+++ b/llvm/tools/obj2yaml/macho2yaml.cpp
@@ -13,8 +13,6 @@
#include "llvm/ObjectYAML/MachOYAML.h"
#include "llvm/Support/ErrorHandling.h"
-#include <string.h> // for memcpy
-
using namespace llvm;
class MachODumper {
@@ -34,24 +32,6 @@ public:
MachO::swapStruct(LC.Data.LCStruct##_data); \
break;
-template <typename SectionType>
-MachOYAML::Section constructSection(SectionType Sec) {
- MachOYAML::Section 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;
- TempSec.reserved3 = 0;
- return TempSec;
-}
-
Expected<std::unique_ptr<MachOYAML::Object>> MachODumper::dump() {
auto Y = make_unique<MachOYAML::Object>();
Y->Header.magic = Obj.getHeader().magic;
@@ -74,40 +54,6 @@ Expected<std::unique_ptr<MachOYAML::Object>> MachODumper::dump() {
break;
#include "llvm/Support/MachO.def"
}
- if (LoadCmd.C.cmd == MachO::LC_SEGMENT) {
- auto End = LoadCmd.Ptr + LoadCmd.C.cmdsize;
- const MachO::section *Curr = reinterpret_cast<const MachO::section *>(
- LoadCmd.Ptr + sizeof(MachO::segment_command));
- for (; reinterpret_cast<const void *>(Curr) < End; Curr++) {
- if (Obj.isLittleEndian() != sys::IsLittleEndianHost) {
- MachO::section Sec;
- memcpy((void *)&Sec, Curr, sizeof(MachO::section));
- MachO::swapStruct(Sec);
- LC.Sections.push_back(constructSection(Sec));
- } else {
- LC.Sections.push_back(constructSection(*Curr));
- }
- }
- } else if (LoadCmd.C.cmd == MachO::LC_SEGMENT_64) {
- auto End = LoadCmd.Ptr + LoadCmd.C.cmdsize;
- const MachO::section_64 *Curr =
- reinterpret_cast<const MachO::section_64 *>(
- LoadCmd.Ptr + sizeof(MachO::segment_command_64));
- for (; reinterpret_cast<const void *>(Curr) < End; Curr++) {
- MachOYAML::Section TempSec;
- if (Obj.isLittleEndian() != sys::IsLittleEndianHost) {
- MachO::section_64 Sec;
- memcpy((void *)&Sec, Curr, sizeof(MachO::section_64));
- MachO::swapStruct(Sec);
- LC.Sections.push_back(constructSection(Sec));
- TempSec = constructSection(Sec);
- } else {
- TempSec = constructSection(*Curr);
- }
- TempSec.reserved3 = Curr->reserved3;
- LC.Sections.push_back(TempSec);
- }
- }
Y->LoadCommands.push_back(std::move(LC));
}
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index 0e8799e2ce1..772c710c098 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -77,23 +77,6 @@ Error MachOWriter::writeHeader(raw_ostream &OS) {
return Error::success();
}
-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;
-}
-
Error MachOWriter::writeLoadCommands(raw_ostream &OS) {
for (auto &LC : Obj.LoadCommands) {
size_t BytesWritten = 0;
@@ -113,21 +96,6 @@ Error MachOWriter::writeLoadCommands(raw_ostream &OS) {
#include "llvm/Support/MachO.def"
}
- if(LC.Data.load_command_data.cmd == MachO::LC_SEGMENT) {
- for(auto Sec : LC.Sections) {
- auto TempSec = constructSection<MachO::section>(Sec);
- OS.write(reinterpret_cast<const char *>(&(TempSec)), sizeof(MachO::section));
- BytesWritten += sizeof(MachO::section);
- }
- } else if(LC.Data.load_command_data.cmd == MachO::LC_SEGMENT_64) {
- for(auto Sec : LC.Sections) {
- auto TempSec = constructSection<MachO::section_64>(Sec);
- TempSec.reserved3 = Sec.reserved3;
- OS.write(reinterpret_cast<const char *>(&(TempSec)), sizeof(MachO::section_64));
- BytesWritten += sizeof(MachO::section_64);
- }
- }
-
auto BytesRemaining =
LC.Data.load_command_data.cmdsize - BytesWritten;
if (BytesRemaining > 0) {
OpenPOWER on IntegriCloud