summaryrefslogtreecommitdiffstats
path: root/llvm/tools/yaml2obj/yaml2macho.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2macho.cpp')
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index 2df03fd3901..9dcc7d1d759 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -262,6 +262,12 @@ Error MachOWriter::writeLoadCommands(raw_ostream &OS) {
return Error::success();
}
+static bool isVirtualSection(uint8_t type) {
+ return (type == MachO::S_ZEROFILL ||
+ type == MachO::S_GB_ZEROFILL ||
+ type == MachO::S_THREAD_LOCAL_ZEROFILL);
+}
+
Error MachOWriter::writeSectionData(raw_ostream &OS) {
bool FoundLinkEditSeg = false;
for (auto &LC : Obj.LoadCommands) {
@@ -300,10 +306,16 @@ Error MachOWriter::writeSectionData(raw_ostream &OS) {
} else if (0 == strncmp(&Sec.sectname[0], "__debug_line", 16)) {
DWARFYAML::EmitDebugLine(OS, Obj.DWARF);
}
- } else {
- // Fills section data with 0xDEADBEEF
- Fill(OS, Sec.size, 0xDEADBEEFu);
+
+ continue;
}
+
+ // Skip if it's a virtual section.
+ if (isVirtualSection(Sec.flags & MachO::SECTION_TYPE))
+ continue;
+
+ // Fill section data with 0xDEADBEEF
+ Fill(OS, Sec.size, 0xDEADBEEFu);
}
uint64_t segSize = is64Bit ? LC.Data.segment_command_64_data.filesize
: LC.Data.segment_command_data.filesize;
OpenPOWER on IntegriCloud