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

		if (cu.getLength() <= 1) {
			return Collections.emptyList();
		}

		List<Reference> offcuts = new ArrayList<>();
		ReferenceManager refMgr = program.getReferenceManager();
		AddressSet set = new AddressSet(cu.getMinAddress().add(1), cu.getMaxAddress());
		AddressIterator it = refMgr.getReferenceDestinationIterator(set, true);
		while (it.hasNext()) {
			Address addr = it.next();
			ReferenceIterator refIter = refMgr.getReferencesTo(addr);
			while (refIter.hasNext()) {
				if (offcuts.size() - max == 0) {
					break;
				}

				Reference ref = refIter.next();
				offcuts.add(ref);
			}
		}

		return offcuts;
	}
Returns an array containing all offcut xref references to the specified code unit

@param cu the code unit to generate the offcut xrefs
@param max max number of offcut xrefs to get, or -1 to get all offcut references
@return array of all offcut xrefs to the code unit
Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtils.java