public static void fixupExternalLibrary(Program program, List<String> libraryPaths,
			int libraryOrdinal, String symbol) throws Exception {

		switch (libraryOrdinal) {
			case DyldInfoCommandConstants.BIND_SPECIAL_DYLIB_SELF:
			case DyldInfoCommandConstants.BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE:
			case DyldInfoCommandConstants.BIND_SPECIAL_DYLIB_FLAT_LOOKUP:
			case DyldInfoCommandConstants.BIND_SPECIAL_DYLIB_WEAK_LOOKUP:
				return;
		}

		ExternalManager extManager = program.getExternalManager();
		int libraryIndex = libraryOrdinal - 1;
		if (libraryIndex < 0 || libraryIndex >= libraryPaths.size()) {
			throw new Exception(
				"Library ordinal '%d' outside of expected range".formatted(libraryOrdinal));
		}
		String libraryName =
			SymbolUtilities.replaceInvalidChars(libraryPaths.get(libraryIndex), true);
		Library library = extManager.getExternalLibrary(libraryName);
		if (library == null) {
			throw new Exception(
				"Library '%s' not found in external program list".formatted(libraryName));
		}
		ExternalLocation loc =
			extManager.getUniqueExternalLocation(Library.UNKNOWN, symbol);
		if (loc != null) {
			try {
				loc.setName(library, symbol, SourceType.IMPORTED);
			}
			catch (InvalidInputException e) {
				throw new Exception(e.getMessage());
			}
		}
	}
Associates the given {@link Symbol} with the correct external {@link Library} (fixing
the {@code <EXTERNAL>} association)

@param program The {@link Program}
@param libraryPaths A {@link List} of library paths
@param libraryOrdinal The library ordinal
@param symbol The symbol
@throws Exception if an unexpected problem occurs
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java