summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ObjectYAML/MachOYAML.cpp
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-05-18 16:17:23 +0000
committerChris Bieneman <beanz@apple.com>2016-05-18 16:17:23 +0000
commit2de17d49dd0fef25849c7c4b0843dbef8a0062e3 (patch)
tree42401a5108c103c569169d0c66cf241c0cdb01b2 /llvm/lib/ObjectYAML/MachOYAML.cpp
parent5a6d2985d747223350f93274187be97e3073c1e4 (diff)
downloadbcm5719-llvm-2de17d49dd0fef25849c7c4b0843dbef8a0062e3.tar.gz
bcm5719-llvm-2de17d49dd0fef25849c7c4b0843dbef8a0062e3.zip
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. llvm-svn: 269953
Diffstat (limited to 'llvm/lib/ObjectYAML/MachOYAML.cpp')
-rw-r--r--llvm/lib/ObjectYAML/MachOYAML.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/MachOYAML.cpp b/llvm/lib/ObjectYAML/MachOYAML.cpp
index b98d4622a36..2faefca432e 100644
--- a/llvm/lib/ObjectYAML/MachOYAML.cpp
+++ b/llvm/lib/ObjectYAML/MachOYAML.cpp
@@ -15,7 +15,7 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/Format.h"
-#include <string.h> // For memcpy and memset.
+#include <string.h> // For memcpy, memset and strnlen.
namespace llvm {
@@ -25,7 +25,8 @@ namespace yaml {
void ScalarTraits<char_16>::output(const char_16 &Val, void *,
llvm::raw_ostream &Out) {
- Out << Val;
+ auto Len = strnlen(&Val[0], 16);
+ Out << StringRef(&Val[0], Len);
}
StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
@@ -110,20 +111,42 @@ void MappingTraits<MachOYAML::LoadCommand>::mapping(
switch (LoadCommand.Data.load_command_data.cmd) {
#include "llvm/Support/MachO.def"
}
+ if (LoadCommand.Data.load_command_data.cmd == MachO::LC_SEGMENT ||
+ LoadCommand.Data.load_command_data.cmd == MachO::LC_SEGMENT_64) {
+ IO.mapOptional("Sections", LoadCommand.Sections);
+ }
}
void MappingTraits<MachO::dyld_info_command>::mapping(
IO &IO, MachO::dyld_info_command &LoadCommand) {
IO.mapRequired("rebase_off", LoadCommand.rebase_off);
IO.mapRequired("rebase_size", LoadCommand.rebase_size);
- IO.mapRequired("bind_off", LoadCommand.bind_size);
+ IO.mapRequired("bind_off", LoadCommand.bind_off);
+ IO.mapRequired("bind_size", LoadCommand.bind_size);
IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
- IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_size);
+ IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
+ IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
IO.mapRequired("export_off", LoadCommand.export_off);
IO.mapRequired("export_size", LoadCommand.export_size);
}
+void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
+ MachOYAML::Section &Section) {
+ IO.mapRequired("sectname", Section.sectname);
+ IO.mapRequired("segname", Section.segname);
+ IO.mapRequired("addr", Section.addr);
+ IO.mapRequired("size", Section.size);
+ IO.mapRequired("offset", Section.offset);
+ IO.mapRequired("align", Section.align);
+ IO.mapRequired("reloff", Section.reloff);
+ IO.mapRequired("nreloc", Section.nreloc);
+ IO.mapRequired("flags", Section.flags);
+ IO.mapRequired("reserved1", Section.reserved1);
+ IO.mapRequired("reserved2", Section.reserved2);
+ IO.mapOptional("reserved3", Section.reserved3);
+}
+
void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
IO.mapRequired("name", DylibStruct.name);
IO.mapRequired("timestamp", DylibStruct.timestamp);
OpenPOWER on IntegriCloud