public final static List<Reference> getXReferences(CodeUnit cu, int max) {
		Program program = cu.getProgram();
		if (program == null) {
			Collections.emptyList();
		}

		// lookup the direct xrefs to the current code unit
		List<Reference> xrefs = new ArrayList<>();
		Address minAddress = cu.getMinAddress();
		ReferenceIterator it = program.getReferenceManager().getReferencesTo(minAddress);
		while (it.hasNext()) {
			if (xrefs.size() - max == 0) {
				break;
			}

			Reference ref = it.next();
			xrefs.add(ref);
		}

		// Check for thunk reference
		Function func = program.getFunctionManager().getFunctionAt(minAddress);
		if (func != null) {
			Address[] thunkAddrs = func.getFunctionThunkAddresses();
			if (thunkAddrs != null) {
				for (Address thunkAddr : thunkAddrs) {
					xrefs.add(new ThunkReference(thunkAddr, func.getEntryPoint()));
				}
			}
		}
		return xrefs;
	}
Returns an array containing the first <b><code>max</code></b>
direct xref references to the specified code unit.

@param cu the code unit to generate the xrefs
@param max max number of xrefs to get, or -1 to get all references

@return array first <b><code>max</code></b> xrefs to the code unit
Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtils.java