public boolean addReference(CodeUnit fromCodeUnit, int opIndex, String extName, String path,
			Address addr, String label) {

		if (!confirmPossibleReferenceRemoval(fromCodeUnit, opIndex, null)) {
			return false;
		}

		Program p = fromCodeUnit.getProgram();

		// TODO: Add RefType entry to External Reference editor panel (infer default for now to avoid merge conflict)

		RefType refType = RefType.DATA;
		if (fromCodeUnit instanceof Instruction) {
			FlowType flowType = ((Instruction) fromCodeUnit).getFlowType();
			if (flowType.isComputed()) {
				if (flowType.isCall()) {
					refType = RefType.COMPUTED_CALL;
				}
				else if (flowType.isJump()) {
					refType = RefType.COMPUTED_JUMP;
				}
			}
			else if (flowType.isCall()) {
				refType = RefType.UNCONDITIONAL_CALL;
			}
			else if (flowType.isJump()) {
				refType = RefType.UNCONDITIONAL_JUMP;
			}
		}

		CompoundCmd<Program> cmd = new CompoundCmd<>("Add External Reference");
		buildAddExtRefCmd(cmd, p, fromCodeUnit.getMinAddress(), opIndex, extName, path, addr, label,
			refType);

		return tool.execute(cmd, p);
	}
Add memory reference

@param fromCodeUnit
@param opIndex
@param toAddr
@param isOffsetRef
@param offset
@param refType
@return true if add was successful
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/ReferencesPlugin.java