protected void processMemoryBlocks(MachHeader header, String source, boolean processSections,
			boolean allowZeroAddr) throws Exception {

		if (header.getFileType() == MachHeaderFileTypes.MH_DYLIB_STUB) {
			return;
		}

		Set<Section> overlaySections = new HashSet<>();

		// Create memory blocks for segments.
		List<SegmentCommand> segments = header.getAllSegments();
		monitor.initialize(segments.size(), "Processing segments for " + source + "...");
		for (SegmentCommand segment : segments) {
			monitor.increment();

			if (segment.getSegmentName().equals(SegmentNames.SEG_PAGEZERO)) {
				continue;
			}

			if (segment.getVMsize() > 0 && (allowZeroAddr || segment.getVMaddress() != 0)) {
				if (segment.getFileSize() > 0) {
					if (createMemoryBlock(segment.getSegmentName(),
						space.getAddress(segment.getVMaddress()), segment.getFileOffset(),
						segment.getFileSize(), segment.getSegmentName(), source, segment.isRead(),
						segment.isWrite(), segment.isExecute(), false, false) == null) {
						log.appendMsg(String.format("Failed to create block: %s 0x%x 0x%x",
							segment.getSegmentName(), segment.getVMaddress(), segment.getVMsize()));
					}
				}
				if (segment.getVMsize() > segment.getFileSize()) {
					// Pad the remaining address range with uninitialized data
					if (createMemoryBlock(segment.getSegmentName(),
						space.getAddress(segment.getVMaddress()).add(segment.getFileSize()), 0,
						segment.getVMsize() - segment.getFileSize(), segment.getSegmentName(),
						source, segment.isRead(), segment.isWrite(), segment.isExecute(),
						true, false) == null) {
						log.appendMsg(String.format("Failed to create block: %s 0x%x 0x%x",
							segment.getSegmentName(), segment.getVMaddress(), segment.getVMsize()));
					}
				}
			}
			else if (segment.getVMaddress() != 0 && segment.getVMsize() == 0 &&
				segment.getFileSize() > 0) {
				MemoryBlock overlayBlock = createMemoryBlock(segment.getSegmentName(),
					space.getAddress(segment.getVMaddress()), segment.getFileOffset(),
					segment.getFileSize(), segment.getSegmentName(), source, true, false, false,
					false, true);
				if (overlayBlock == null) {
					log.appendMsg(String.format("Failed to create overlay block: %s 0x%x 0x%x",
						segment.getSegmentName(), segment.getVMaddress(), segment.getVMsize()));
				}
				else {
					segmentOverlayMap.put(segment.getSegmentName(), overlayBlock.getStart().getAddressSpace());
					overlaySections.addAll(segment.getSections());
				}
			}
		}

		// Create memory blocks for sections.  They will be in the segments we just created, so the
		// segment blocks will be split and possibly replaced.
		if (processSections) {
			List<Section> sections = header.getAllSections();
			monitor.initialize(sections.size(), "Processing sections for " + source + "...");
			for (Section section : sections) {
				monitor.increment();
				AddressSpace sectionSpace = overlaySections.contains(section)
						? segmentOverlayMap.get(section.getSegmentName())
						: space;
				if (section.getSize() > 0 &&
					(section.getOffset() > 0 || section.getType() == SectionTypes.S_ZEROFILL) &&
					(allowZeroAddr || section.getAddress() != 0)) {
					if (createMemoryBlock(section.getSectionName(),
						sectionSpace.getAddress(section.getAddress()), section.getOffset(),
						section.getSize(), section.getSegmentName(), source, section.isRead(),
						section.isWrite(), section.isExecute(),
						section.getType() == SectionTypes.S_ZEROFILL, false) == null) {
						log.appendMsg(String.format("Failed to create block: %s.%s 0x%x 0x%x %s",
							section.getSegmentName(), section.getSectionName(),
							section.getAddress(), section.getSize(), source));
					}
				}
			}
		}
	}
Creates memory blocks for the given header.  

@param header The Mach-O header to process for memory block creation.
@param source A name that represents where the memory blocks came from.
@param processSections True to split segments into their sections.
@param allowZeroAddr True if memory blocks at address 0 should be processed; otherwise, 
  false.
@throws Exception If there was a problem processing the memory blocks.
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java