private AddressSetView removeDefined(Program program, AddressSetView addrSet) {
		AddressSet subSet = new AddressSet();

		// find defined data that should be removed
		DataIterator definedData = program.getListing().getDefinedData(addrSet, true);
		for (Data data : definedData) {
			DataType dataType = data.getDataType();			
			if (dataType instanceof Undefined) {
				continue;
			}
			
			if (data.isPointer()) {
				continue;
			}

			// anything else, add to subset to be removed
			subSet.add(data.getMinAddress(), data.getMaxAddress());
		}
		addrSet = addrSet.subtract(subSet);
		
		// Find defined instructions that should be removed
		subSet = new AddressSet();
		InstructionIterator instructions = program.getListing().getInstructions(addrSet, true);
		for (Instruction instruction : instructions) {
			subSet.add(instruction.getMinAddress(), instruction.getMaxAddress());
		}
		addrSet = addrSet.subtract(subSet);
		
		return addrSet;
	}
Remove any addresses from set where instructions or defined data exists that would
get filtered during address table creation.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/AddressTableAnalyzer.java