private void processMemoryBlocks(Program program, FileBytes fileBytes,
			SegmentedAddressSpace space, MzExecutable mz, Set<RelocationFixup> relocationFixups,
			MessageLog log, TaskMonitor monitor) throws Exception {
		monitor.setMessage("Processing memory blocks...");

		OldDOSHeader header = mz.getHeader();
		BinaryReader reader = mz.getBinaryReader();

		// Use relocations to discover what segments are in use.
		// We also know about our desired load module segment, so add that too.	
		Set<SegmentedAddress> knownSegments = new TreeSet<>();
		relocationFixups.stream()
				.filter(RelocationFixup::valid)
				.forEach(rf -> knownSegments.add(space.getAddress(rf.segment, 0)));
		knownSegments.add(space.getAddress(INITIAL_SEGMENT_VAL, 0));
		if (header.e_cs() > 0) {
			knownSegments.add(space.getAddress((INITIAL_SEGMENT_VAL + header.e_cs()) & 0xffff, 0));
		}
		// Allocate an initialized memory block for each segment we know about
		int endOffset = pagesToBytes(Short.toUnsignedInt(header.e_cp()) - 1) +
			Short.toUnsignedInt(header.e_cblp());
		if (endOffset > reader.length()) {
			log.appendMsg(
				"File is 0x%x bytes but header reports 0x%x".formatted(reader.length(), endOffset));
			endOffset = (int) reader.length();
		}
		MemoryBlock lastBlock = null;
		List<SegmentedAddress> orderedSegments = new ArrayList<>(knownSegments);
		for (int i = 0; i < orderedSegments.size(); i++) {
			SegmentedAddress segmentAddr = orderedSegments.get(i);

			int segmentFileOffset = addressToFileOffset(
				(segmentAddr.getSegment() - INITIAL_SEGMENT_VAL) & 0xffff, 0, header);
			if (segmentFileOffset < 0) {
				log.appendMsg("Invalid segment start file location: " + segmentFileOffset);
				continue;
			}

			int numBytes = 0;
			if (i + 1 < orderedSegments.size()) {
				SegmentedAddress end = orderedSegments.get(i + 1);
				int nextSegmentFileOffset = addressToFileOffset(
					(end.getSegment() - INITIAL_SEGMENT_VAL) & 0xffff, 0, header);
				numBytes = nextSegmentFileOffset - segmentFileOffset;
			}
			else {
				// last segment length
				numBytes = endOffset - segmentFileOffset;
			}
			if (numBytes <= 0) {
				log.appendMsg("No file data available for defined segment at: " + segmentAddr);
				continue;
			}
			int numUninitBytes = 0;
			if (segmentFileOffset + numBytes > endOffset) {
				int calcNumBytes = numBytes;
				if (segmentFileOffset > endOffset) {
					numBytes = 0;
					numUninitBytes = calcNumBytes;
				}
				else {
					numBytes = endOffset - segmentFileOffset;
					numUninitBytes = calcNumBytes - numBytes;
				}
			}
			if (numBytes > 0) {
				MemoryBlock block = MemoryBlockUtils.createInitializedBlock(program, false,
					"CODE_" + i, segmentAddr, fileBytes, segmentFileOffset, numBytes, "", "mz",
					true, true, true, log);
				if (block != null) {
					lastBlock = block;
				}
			}
			if (numUninitBytes > 0) {
				MemoryBlock block =
					MemoryBlockUtils.createUninitializedBlock(program, false, "CODE_" + i + "u",
						segmentAddr.add(numBytes), numUninitBytes, "", "mz", true, true, false,
						log);
				if (block != null) {
					lastBlock = block;
				}
			}
		}
		if (endOffset < reader.length()) {
			int extraByteCount = (int) reader.length() - endOffset;
			log.appendMsg(
				String.format("File contains 0x%x extra bytes starting at file offset 0x%x",
					extraByteCount, endOffset));
		}

		// Allocate an uninitialized memory block for extra minimum required data space
		if (lastBlock != null) {
			int extraAllocSize = paragraphsToBytes(Short.toUnsignedInt(header.e_minalloc()));
			if (extraAllocSize > 0) {
				MemoryBlockUtils.createUninitializedBlock(program, false, "DATA",
					lastBlock.getEnd().add(1), extraAllocSize, "", "mz", true, true, false, log);

			}
		}
	}
Stores a relocation's fixup information

@param relocation The original relocation info
@param address The {@link SegmentedAddress} of the relocation
@param fileOffset The file offset of the relocation
@param segment The fixed-up segment after the relocation is applied
@param valid True if the relocation is valid; otherwise, false
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MzLoader.java