--- a/bin/jdtls.py
+++ b/bin/jdtls.py
@@ -66,7 +66,12 @@
 	system = platform.system()
 
 	if system in ['Linux', 'FreeBSD']:
-		config_dir = 'config_linux'
+		# Gentoo: config_linux names the x86_64 launcher fragment; aarch64
+		# needs its own shared configuration.
+		if platform.machine().lower() in ['aarch64', 'arm64']:
+			config_dir = 'config_linux_arm'
+		else:
+			config_dir = 'config_linux'
 	# or use system == 'Android'
 	elif 'TERMUX_VERSION' in os.environ:
 		config_dir = 'config_linux'
@@ -88,6 +93,8 @@
 		cachedir = Path(os.environ['APPDATA'])
 	elif system == 'Darwin' and 'HOME' in os.environ:
 		cachedir = Path(os.environ['HOME']) / 'Library' / 'Caches'
+	elif system == 'Linux' and os.environ.get('XDG_CACHE_HOME'):
+		cachedir = Path(os.environ['XDG_CACHE_HOME'])
 	elif system == 'Linux' and 'HOME' in os.environ:
 		cachedir = Path(os.environ['HOME']) / '.cache'
 	elif 'TERMUX_VERSION' in os.environ and 'HOME' in os.environ:
@@ -107,6 +114,10 @@
 			action="append",
 			help="An additional JVM option (can be used multiple times. Note, use with equal sign. For example: --jvm-arg=-Dlog.level=ALL")
 	parser.add_argument("-data", default=jdtls_data_path)
+	# Gentoo: the install tree under /usr/share is read-only, so keep the
+	# per-user OSGi configuration area in the cache dir. The shared,
+	# read-only config_linux* area is cascaded underneath it.
+	parser.add_argument("-configuration", default=None)
 
 	known_args, args = parser.parse_known_args(args)
 	java_executable = get_java_executable(known_args)
@@ -114,6 +125,8 @@
 
 	jdtls_base_path = Path(__file__).parent.parent
 	shared_config_path = get_shared_config_path(jdtls_base_path)
+	if known_args.configuration is None:
+		known_args.configuration = str(cachedir / os.path.basename(shared_config_path))
 	jar_path = find_equinox_launcher(jdtls_base_path)
 
 	exec_args = ["-Declipse.application=org.eclipse.jdt.ls.core.id1",
@@ -129,6 +142,7 @@
 			"--add-opens", "java.base/java.lang=ALL-UNNAMED"] \
 			+ known_args.jvm_arg \
 			+ ["-jar", jar_path,
+			"-configuration", known_args.configuration,
 			"-data", known_args.data] \
 			+ args
 
