private CodeUnit getSmallestCodeUnitAt(Listing listing, Address addr) {
		CodeUnit cu = listing.getCodeUnitContaining(addr);
		if (cu instanceof Data) {
			Data data = (Data) cu;
			if ((data.getNumComponents() == 0) || (data.isUnion()) || (data.isArray())) {
				return data;
			}
			long diff = addr.subtract(data.getMinAddress());
			return data.getPrimitiveAt((int) (diff));
		}
		return cu;
	}
Add memory references.
@param fromAddr reference source
@param toSet set of addresses which make up reference destinations.
Only those addresses on code where a code unit exists will be considered.
@param refType reference type to be applied.
@param source the source of the reference
@param opIndex source operand index
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/AddMemRefsCmd.java