public static byte[] create(int magic, String name, long vmAddr, long vmSize, long fileOffset,
			long fileSize, int maxProt, int initProt, int flags) throws MachException {

		if (name.length() > 16) {
			throw new MachException("Segment name cannot exceed 16 bytes: " + name);
		}

		DataConverter conv = DataConverter.getInstance(magic == MachConstants.MH_MAGIC);
		boolean is64bit = magic == MachConstants.MH_CIGAM_64 || magic == MachConstants.MH_MAGIC_64;

		// Segment Command
		byte[] bytes = new byte[size(magic)];
		conv.putInt(bytes, 0x00,
			is64bit ? LoadCommandTypes.LC_SEGMENT_64 : LoadCommandTypes.LC_SEGMENT);
		conv.putInt(bytes, 0x04, bytes.length);
		byte[] nameBytes = name.getBytes(StandardCharsets.US_ASCII);
		System.arraycopy(nameBytes, 0, bytes, 0x8, nameBytes.length);
		if (is64bit) {
			conv.putLong(bytes, 0x18, vmAddr);
			conv.putLong(bytes, 0x20, vmSize);
			conv.putLong(bytes, 0x28, fileOffset);
			conv.putLong(bytes, 0x30, fileSize);
			conv.putInt(bytes, 0x38, maxProt);
			conv.putInt(bytes, 0x3c, initProt);
			conv.putInt(bytes, 0x40, 0);
			conv.putInt(bytes, 0x44, flags);
		}
		else {
			conv.putInt(bytes, 0x18, (int) vmAddr);
			conv.putInt(bytes, 0x1c, (int) vmSize);
			conv.putInt(bytes, 0x20, (int) fileOffset);
			conv.putInt(bytes, 0x24, (int) fileSize);
			conv.putInt(bytes, 0x28, maxProt);
			conv.putInt(bytes, 0x2c, initProt);
			conv.putInt(bytes, 0x30, 0);
			conv.putInt(bytes, 0x34, flags);
		}

		return bytes;
	}
Creates a new segment command byte array.
<p>
NOTE: The new segment will have 0 sections.

@param magic The magic
@param name The name of the segment (must be less than or equal to 16 bytes)
@param vmAddr The address of the start of the segment
@param vmSize The size of the segment in memory
@param fileOffset The file offset of the start of the segment
@param fileSize The size of the segment on disk
@param maxProt The maximum protections of the segment
@param initProt The initial protection of the segment
@param flags The segment flags
@return The new segment in byte array form
@throws MachException if an invalid magic value was passed in (see {@link MachConstants}), or
  if the desired segment name exceeds 16 bytes
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SegmentCommand.java