public static DWARFUnitHeader read(DWARFProgram dprog, BinaryReader reader,
			BinaryReader abbrReader, int unitNumber, TaskMonitor monitor)
			throws DWARFException, IOException, CancelledException {
		// unit_length : dwarf_length
		// version : 2 bytes
		// unit type : 1 byte [ version >= 5 ]

		long startOffset = reader.getPointerIndex();
		DWARFLengthValue lengthInfo = DWARFLengthValue.read(reader, dprog.getDefaultIntSize());
		if (lengthInfo == null) {
			return null;
		}

		long endOffset = reader.getPointerIndex() + lengthInfo.length();
		short version = reader.readNextShort();
		if (version < 2) {
			throw new DWARFException("Unsupported DWARF version [%d]".formatted(version));
		}

		DWARFUnitHeader partial = new DWARFUnitHeader(dprog, startOffset, endOffset,
			lengthInfo.intSize(), version, unitNumber);

		if (2 <= version && version <= 4) {
			return DWARFCompilationUnit.readV4(partial, reader, abbrReader, monitor);
		}
		int unitType = reader.readNextUnsignedByte();
		switch (unitType) {
			case DWARFUnitType.DW_UT_compile:
				return DWARFCompilationUnit.readV5(partial, reader, abbrReader, monitor);
			case DWARFUnitType.DW_UT_type:
			case DWARFUnitType.DW_UT_partial:
			case DWARFUnitType.DW_UT_skeleton:
			case DWARFUnitType.DW_UT_split_compile:
			case DWARFUnitType.DW_UT_split_type:
			default:
				throw new DWARFException("Unsupported unitType %d, %s".formatted(unitType,
					DWARFUtil.toString(DWARFUnitType.class, unitType)));
		}
	}
Reads the initial fields found in a unit header.

@param dprog {@link DWARFProgram}
@param reader {@link BinaryReader} stream
@param abbrReader  {@link BinaryReader} .debug_abbr stream
@param unitNumber ordinal of this item
@param monitor {@link TaskMonitor}
@return a unit header (only comp units for now), or null if at end-of-list
@throws DWARFException if invalid dwarf data
@throws IOException if error reading data
@throws CancelledException if cancelled
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFUnitHeader.java