private static Address getCodeUnitAddress(Program p, Address addr) {
		if (addr == null) {
			NullPointerException exc =
				new NullPointerException("Null address passed to ProgramLocation");
			showException(exc);
		}

		if (p == null) {
			return addr;
		}
		CodeUnit cu = p.getListing().getCodeUnitContaining(addr);

		// if the code unit is data, get the lowest sub-data containing the address
		if (cu instanceof Data) {
			Data data = (Data) cu;
			cu = data.getPrimitiveAt((int) addr.subtract(data.getAddress()));
		}

		if (cu != null) {
			return cu.getMinAddress();
		}
		return addr;
	}
Get the program location for the given program and save state object.

@param program the program for the location
@param saveState the state to restore
@return the restored program location
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/ProgramLocation.java