mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-07-30 07:18:37 -09:00
Add OpenBSD support for x86_64 and arm_64.
This commit is contained in:
@@ -84,6 +84,8 @@ model {
|
|||||||
targetPlatform "mac_arm_64"
|
targetPlatform "mac_arm_64"
|
||||||
targetPlatform "freebsd_x86_64"
|
targetPlatform "freebsd_x86_64"
|
||||||
targetPlatform "freebsd_arm_64"
|
targetPlatform "freebsd_arm_64"
|
||||||
|
targetPlatform "openbsd_x86_64"
|
||||||
|
targetPlatform "openbsd_arm_64"
|
||||||
sources {
|
sources {
|
||||||
c {
|
c {
|
||||||
source {
|
source {
|
||||||
@@ -108,6 +110,8 @@ model {
|
|||||||
targetPlatform "mac_arm_64"
|
targetPlatform "mac_arm_64"
|
||||||
targetPlatform "freebsd_x86_64"
|
targetPlatform "freebsd_x86_64"
|
||||||
targetPlatform "freebsd_arm_64"
|
targetPlatform "freebsd_arm_64"
|
||||||
|
targetPlatform "openbsd_x86_64"
|
||||||
|
targetPlatform "openbsd_arm_64"
|
||||||
sources {
|
sources {
|
||||||
c {
|
c {
|
||||||
source {
|
source {
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ model {
|
|||||||
gcc(Gcc).target(current)
|
gcc(Gcc).target(current)
|
||||||
clang(Clang).target(current)
|
clang(Clang).target(current)
|
||||||
}
|
}
|
||||||
|
if (isOpenBSD(current)) {
|
||||||
|
gcc(Gcc).target(current)
|
||||||
|
clang(Clang).target(current)
|
||||||
|
}
|
||||||
if (isWindows(current) && VISUAL_STUDIO_INSTALL_DIR) {
|
if (isWindows(current) && VISUAL_STUDIO_INSTALL_DIR) {
|
||||||
// https://github.com/gradle/gradle-native/issues/617#issuecomment-575735288
|
// https://github.com/gradle/gradle-native/issues/617#issuecomment-575735288
|
||||||
visualCpp(VisualCpp) {
|
visualCpp(VisualCpp) {
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ project.ext.PLATFORMS = [
|
|||||||
[name: "mac_x86_64", os: "osx", arch: "x86_64"],
|
[name: "mac_x86_64", os: "osx", arch: "x86_64"],
|
||||||
[name: "mac_arm_64", os: "osx", arch: "arm64"],
|
[name: "mac_arm_64", os: "osx", arch: "arm64"],
|
||||||
[name: "freebsd_x86_64", os: "freebsd", arch: "x86_64"],
|
[name: "freebsd_x86_64", os: "freebsd", arch: "x86_64"],
|
||||||
[name: "freebsd_arm_64", os: "freebsd", arch: "arm64"]
|
[name: "freebsd_arm_64", os: "freebsd", arch: "arm64"],
|
||||||
|
[name: "openbsd_x86_64", os: "openbsd", arch: "x86_64"],
|
||||||
|
[name: "openbsd_arm_64", os: "openbsd", arch: "arm64"]
|
||||||
]
|
]
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
@@ -57,6 +59,9 @@ ext.getCurrentPlatformName = {
|
|||||||
case ~/FreeBSD.*/:
|
case ~/FreeBSD.*/:
|
||||||
os = "freebsd"
|
os = "freebsd"
|
||||||
break
|
break
|
||||||
|
case ~/OpenBSD.*/:
|
||||||
|
os = "openbsd"
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
throw new GradleException("Unrecognized platform operating system: $os")
|
throw new GradleException("Unrecognized platform operating system: $os")
|
||||||
}
|
}
|
||||||
@@ -132,6 +137,20 @@ ext.isCurrentFreeBSD = {
|
|||||||
return isFreeBSD(getCurrentPlatformName())
|
return isFreeBSD(getCurrentPlatformName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
* Returns true if the given platform is OpenBSD.
|
||||||
|
*********************************************************************************/
|
||||||
|
ext.isOpenBSD = { platform_name ->
|
||||||
|
return platform_name.startsWith("openbsd")
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
* Returns true if the current platform is OpenBSD.
|
||||||
|
*********************************************************************************/
|
||||||
|
ext.isCurrentOpenBSD = {
|
||||||
|
return isOpenBSD(getCurrentPlatformName())
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
* Returns true if the given platform is Windows.
|
* Returns true if the given platform is Windows.
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ model {
|
|||||||
targetPlatform "mac_arm_64"
|
targetPlatform "mac_arm_64"
|
||||||
targetPlatform "freebsd_x86_64"
|
targetPlatform "freebsd_x86_64"
|
||||||
targetPlatform "freebsd_arm_64"
|
targetPlatform "freebsd_arm_64"
|
||||||
|
targetPlatform "openbsd_x86_64"
|
||||||
|
targetPlatform "openbsd_arm_64"
|
||||||
sources {
|
sources {
|
||||||
cpp {
|
cpp {
|
||||||
// NOTE: The bison/flex generated files are assumed to be up-to-date.
|
// NOTE: The bison/flex generated files are assumed to be up-to-date.
|
||||||
@@ -157,6 +159,8 @@ model {
|
|||||||
targetPlatform "mac_arm_64"
|
targetPlatform "mac_arm_64"
|
||||||
targetPlatform "freebsd_x86_64"
|
targetPlatform "freebsd_x86_64"
|
||||||
targetPlatform "freebsd_arm_64"
|
targetPlatform "freebsd_arm_64"
|
||||||
|
targetPlatform "openbsd_x86_64"
|
||||||
|
targetPlatform "openbsd_arm_64"
|
||||||
sources {
|
sources {
|
||||||
cpp {
|
cpp {
|
||||||
// NOTE: The bison/flex generated files are assumed to be up-to-date.
|
// NOTE: The bison/flex generated files are assumed to be up-to-date.
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ ifeq ($(OS),Darwin)
|
|||||||
OSDIR=mac_x86_64
|
OSDIR=mac_x86_64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),OpenBSD)
|
||||||
|
ifeq ($(ARCH),amd64)
|
||||||
|
ARCH_TYPE=-m64
|
||||||
|
OSDIR=openbsd_x86_64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
CXX=g++ -std=c++11
|
CXX=g++ -std=c++11
|
||||||
|
|
||||||
# Debug flags
|
# Debug flags
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ model {
|
|||||||
targetPlatform "mac_arm_64"
|
targetPlatform "mac_arm_64"
|
||||||
targetPlatform "freebsd_x86_64"
|
targetPlatform "freebsd_x86_64"
|
||||||
targetPlatform "freebsd_arm_64"
|
targetPlatform "freebsd_arm_64"
|
||||||
|
targetPlatform "openbsd_x86_64"
|
||||||
|
targetPlatform "openbsd_arm_64"
|
||||||
|
|
||||||
sources {
|
sources {
|
||||||
c {
|
c {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -80,6 +80,16 @@ public enum Platform {
|
|||||||
*/
|
*/
|
||||||
FREEBSD_ARM_64(OperatingSystem.FREE_BSD, Architecture.ARM_64, "freebsd_arm_64", ".so", ""),
|
FREEBSD_ARM_64(OperatingSystem.FREE_BSD, Architecture.ARM_64, "freebsd_arm_64", ".so", ""),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies a OpenBSD x86 64-bit OS.
|
||||||
|
*/
|
||||||
|
OPENBSD_X86_64(OperatingSystem.OPEN_BSD, Architecture.X86_64, "openbsd_x86_64", ".so", ""),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifies a OpenBSD ARM 64-bit OS.
|
||||||
|
*/
|
||||||
|
OPENBSD_ARM_64(OperatingSystem.OPEN_BSD, Architecture.ARM_64, "openbsd_arm_64", ".so", ""),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies an unsupported OS.
|
* Identifies an unsupported OS.
|
||||||
*/
|
*/
|
||||||
@@ -234,6 +244,11 @@ public enum Platform {
|
|||||||
paths.add("/System/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_x86_64");
|
paths.add("/System/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_x86_64");
|
||||||
paths.add("/System/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_x86_64h");
|
paths.add("/System/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_x86_64h");
|
||||||
}
|
}
|
||||||
|
else if (operatingSystem == OperatingSystem.OPEN_BSD) {
|
||||||
|
paths.add("/usr/lib");
|
||||||
|
paths.add("/usr/X11R6/lib");
|
||||||
|
paths.add("/usr/local/lib");
|
||||||
|
}
|
||||||
else if (CURRENT_PLATFORM == WIN_X86_64) {
|
else if (CURRENT_PLATFORM == WIN_X86_64) {
|
||||||
String windir = System.getenv("SystemRoot");
|
String windir = System.getenv("SystemRoot");
|
||||||
if (windir != null) {
|
if (windir != null) {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -20,6 +20,7 @@ public enum OperatingSystem {
|
|||||||
LINUX("Linux"),
|
LINUX("Linux"),
|
||||||
MAC_OS_X("Mac OS X"),
|
MAC_OS_X("Mac OS X"),
|
||||||
FREE_BSD("FreeBSD"),
|
FREE_BSD("FreeBSD"),
|
||||||
|
OPEN_BSD("OpenBSD"),
|
||||||
UNSUPPORTED("Unsupported Operating System");
|
UNSUPPORTED("Unsupported Operating System");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ public class ApplicationUtilities {
|
|||||||
case WINDOWS -> new File(getEnvFile("LOCALAPPDATA", true), appName);
|
case WINDOWS -> new File(getEnvFile("LOCALAPPDATA", true), appName);
|
||||||
case LINUX -> new File("/var/tmp/" + userDirName);
|
case LINUX -> new File("/var/tmp/" + userDirName);
|
||||||
case FREE_BSD -> new File("/var/tmp/" + userDirName);
|
case FREE_BSD -> new File("/var/tmp/" + userDirName);
|
||||||
|
case OPEN_BSD -> new File("/var/tmp/" + userDirName);
|
||||||
case MAC_OS_X -> new File("/var/tmp/" + userDirName);
|
case MAC_OS_X -> new File("/var/tmp/" + userDirName);
|
||||||
default -> throw new FileNotFoundException(
|
default -> throw new FileNotFoundException(
|
||||||
"Failed to find the user cache directory: Unsupported operating system.");
|
"Failed to find the user cache directory: Unsupported operating system.");
|
||||||
@@ -275,6 +276,7 @@ public class ApplicationUtilities {
|
|||||||
case WINDOWS -> new File(getEnvFile("APPDATA", true), versionedSubdir);
|
case WINDOWS -> new File(getEnvFile("APPDATA", true), versionedSubdir);
|
||||||
case LINUX -> new File(userHomeDir, ".config/" + versionedSubdir);
|
case LINUX -> new File(userHomeDir, ".config/" + versionedSubdir);
|
||||||
case FREE_BSD -> new File(userHomeDir, ".config/" + versionedSubdir);
|
case FREE_BSD -> new File(userHomeDir, ".config/" + versionedSubdir);
|
||||||
|
case OPEN_BSD -> new File(userHomeDir, ".config/" + versionedSubdir);
|
||||||
case MAC_OS_X -> new File(userHomeDir, "Library/" + versionedSubdir);
|
case MAC_OS_X -> new File(userHomeDir, "Library/" + versionedSubdir);
|
||||||
default -> throw new FileNotFoundException(
|
default -> throw new FileNotFoundException(
|
||||||
"Failed to find the user settings directory: Unsupported operating system.");
|
"Failed to find the user settings directory: Unsupported operating system.");
|
||||||
|
|||||||
@@ -453,6 +453,7 @@ public class AppConfig {
|
|||||||
new File(localAppDataDirPath, appName + "/" + userSettingsDirName);
|
new File(localAppDataDirPath, appName + "/" + userSettingsDirName);
|
||||||
break;
|
break;
|
||||||
case LINUX:
|
case LINUX:
|
||||||
|
case OPEN_BSD:
|
||||||
userSettingsDir =
|
userSettingsDir =
|
||||||
new File(userHomeDir, ".config/" + appName + "/" + userSettingsDirName);
|
new File(userHomeDir, ".config/" + appName + "/" + userSettingsDirName);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public abstract class JavaFinder {
|
|||||||
* The different supported platforms (operating systems).
|
* The different supported platforms (operating systems).
|
||||||
*/
|
*/
|
||||||
public enum Platform {
|
public enum Platform {
|
||||||
WINDOWS, MACOS, LINUX;
|
WINDOWS, MACOS, LINUX, OPEN_BSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,6 +54,9 @@ public abstract class JavaFinder {
|
|||||||
if (os.contains("mac")) {
|
if (os.contains("mac")) {
|
||||||
return Platform.MACOS;
|
return Platform.MACOS;
|
||||||
}
|
}
|
||||||
|
if (os.contains("openbsd")) {
|
||||||
|
return Platform.OPEN_BSD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Platform.LINUX;
|
return Platform.LINUX;
|
||||||
}
|
}
|
||||||
@@ -69,6 +72,8 @@ public abstract class JavaFinder {
|
|||||||
return new WindowsJavaFinder();
|
return new WindowsJavaFinder();
|
||||||
case MACOS:
|
case MACOS:
|
||||||
return new MacJavaFinder();
|
return new MacJavaFinder();
|
||||||
|
case OPEN_BSD:
|
||||||
|
return new OpenBSDJavaFinder();
|
||||||
case LINUX:
|
case LINUX:
|
||||||
default:
|
default:
|
||||||
return new LinuxJavaFinder();
|
return new LinuxJavaFinder();
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ghidra.launch;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class responsible for finding Java installations on an OpenBSD system.
|
||||||
|
*/
|
||||||
|
public class OpenBSDJavaFinder extends LinuxJavaFinder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<File> getJavaRootInstallDirs() {
|
||||||
|
File localdir = new File("/usr/local");
|
||||||
|
|
||||||
|
File[] filteredFiles = localdir.listFiles((dir, name) ->
|
||||||
|
name.toLowerCase().startsWith("jdk-")
|
||||||
|
);
|
||||||
|
|
||||||
|
return filteredFiles != null
|
||||||
|
? new ArrayList<>(Arrays.asList(filteredFiles))
|
||||||
|
: new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user