Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions platform/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)

project(platform_vxworks)

if(NOT BN_INTERNAL_BUILD)
add_subdirectory(${PROJECT_SOURCE_DIR}/../.. ${PROJECT_BINARY_DIR}/api)
endif()

file(GLOB SOURCES
*.cpp
*.h)

if(DEMO)
add_library(platform_vxworks STATIC ${SOURCES})
else()
add_library(platform_vxworks SHARED ${SOURCES})
endif()

target_link_libraries(platform_vxworks binaryninjaapi)

set_target_properties(platform_vxworks PROPERTIES
CXX_STANDARD 17
CXX_VISIBILITY_PRESET hidden
CXX_STANDARD_REQUIRED ON
VISIBILITY_INLINES_HIDDEN ON
POSITION_INDEPENDENT_CODE ON)

if(BN_INTERNAL_BUILD)
plugin_rpath(platform_vxworks)
set_target_properties(platform_vxworks PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR}
RUNTIME_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR})
endif()
183 changes: 183 additions & 0 deletions platform/vxworks/platform_vxworks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#include "binaryninjaapi.h"

using namespace BinaryNinja;
using namespace std;

Ref<Platform> g_vxWorksX86, g_vxWorksX64, g_vxWorksArm, g_vxWorksArm64, g_vxWorksThumb;
Ref<Platform> g_vxWorksMips32, g_vxWorksMips64, g_vxWorksPpc32, g_vxWorksPpc64;
Ref<Platform> g_vxWorksRiscV32, g_vxWorksRiscv64;


class VxWorksIntelPlatform : public Platform
{
public:
VxWorksIntelPlatform(Architecture* arch, const std::string& name) : Platform(arch, name)
{
Ref<CallingConvention> cc;
cc = arch->GetCallingConventionByName("cdecl");
if (cc)
{
RegisterDefaultCallingConvention(cc);
RegisterCdeclCallingConvention(cc);
RegisterFastcallCallingConvention(cc);
RegisterStdcallCallingConvention(cc);
}
}
};

class VxWorksArmPlatform : public Platform
{
public:
VxWorksArmPlatform(Architecture* arch, const std::string& name) : Platform(arch, name)
{
Ref<CallingConvention> cc;
cc = arch->GetCallingConventionByName("cdecl");
if (cc)
{
RegisterDefaultCallingConvention(cc);
RegisterCdeclCallingConvention(cc);
RegisterFastcallCallingConvention(cc);
RegisterStdcallCallingConvention(cc);
}
}
};

class VxWorksMipsPlatform : public Platform
{
public:
VxWorksMipsPlatform(Architecture* arch, const std::string& name) : Platform(arch, name)
{
Ref<CallingConvention> cc;
cc = arch->GetCallingConventionByName("o32");
if (cc)
{
RegisterDefaultCallingConvention(cc);
RegisterCdeclCallingConvention(cc);
RegisterFastcallCallingConvention(cc);
RegisterStdcallCallingConvention(cc);
}
}
};

class VxWorksPpcPlatform : public Platform
{
public:
VxWorksPpcPlatform(Architecture* arch, const std::string& name): Platform(arch, name)
{
Ref<CallingConvention> cc;
cc = arch->GetCallingConventionByName("svr4");
if (cc)
RegisterDefaultCallingConvention(cc);
}
};

class VxWorksRiscVPlatform : public Platform
{
public:
VxWorksRiscVPlatform(Architecture* arch, const std::string& name): Platform(arch, name)
{
Ref<CallingConvention> cc;
cc = arch->GetCallingConventionByName("default");
if (cc)
{
RegisterDefaultCallingConvention(cc);
RegisterCdeclCallingConvention(cc);
RegisterFastcallCallingConvention(cc);
RegisterStdcallCallingConvention(cc);
}
}
};

extern "C"
{
BN_DECLARE_CORE_ABI_VERSION

#ifndef DEMO_VERSION
BINARYNINJAPLUGIN void CorePluginDependencies()
{
AddOptionalPluginDependency("arch_x86");
AddOptionalPluginDependency("arch_armv7");
AddOptionalPluginDependency("arch_arm64");
AddOptionalPluginDependency("arch_mips");
AddOptionalPluginDependency("arch_ppc");
AddOptionalPluginDependency("arch_riscv");
}
#endif

#ifdef DEMO_VERSION
bool VxWorksPluginInit()
#else
BINARYNINJAPLUGIN bool CorePluginInit()
#endif
{
Ref<BinaryViewType> vx = BinaryViewType::GetByName("VxWorks");
if (!vx)
return true;

Ref<Architecture> x86 = Architecture::GetByName("x86");
Ref<Architecture> x64 = Architecture::GetByName("x86_64");
if (x86 && x64)
{
g_vxWorksX86 = new VxWorksIntelPlatform(x86, "vxworks-x86");
Platform::Register("vxworks", g_vxWorksX86);
BinaryViewType::RegisterDefaultPlatform("VxWorks", x86, g_vxWorksX86);
g_vxWorksX64 = new VxWorksIntelPlatform(x64, "vxworks-x86_64");
Platform::Register("vxworks", g_vxWorksX64);
BinaryViewType::RegisterDefaultPlatform("VxWorks", x64, g_vxWorksX64);
}

Ref<Architecture> armv7 = Architecture::GetByName("armv7");
Ref<Architecture> thumb2 = Architecture::GetByName("thumb2");
Ref<Architecture> arm64 = Architecture::GetByName("aarch64");
if (armv7 && thumb2)
{
g_vxWorksArm = new VxWorksArmPlatform(armv7, "vxworks-armv7");
Platform::Register("vxworks", g_vxWorksArm);
BinaryViewType::RegisterDefaultPlatform("VxWorks", armv7, g_vxWorksArm);
g_vxWorksThumb = new VxWorksArmPlatform(thumb2, "vxworks-thumb2");
Platform::Register("vxworks", g_vxWorksThumb);
BinaryViewType::RegisterDefaultPlatform("VxWorks", thumb2, g_vxWorksThumb);
g_vxWorksArm64 = new VxWorksArmPlatform(arm64, "vxworks-aarch64");
Platform::Register("vxworks", g_vxWorksArm64);
BinaryViewType::RegisterDefaultPlatform("VxWorks", arm64, g_vxWorksArm64);
}

Ref<Architecture> mips32 = Architecture::GetByName("mips32");
Ref<Architecture> mips64 = Architecture::GetByName("mips64");
if (mips64 && mips32)
{
g_vxWorksMips32 = new VxWorksMipsPlatform(mips32, "vxworks-mips32");
Platform::Register("vxworks", g_vxWorksMips32);
BinaryViewType::RegisterDefaultPlatform("VxWorks", mips32, g_vxWorksMips32);
g_vxWorksMips64 = new VxWorksMipsPlatform(mips64, "vxworks-mips64");
Platform::Register("vxworks", g_vxWorksMips64);
BinaryViewType::RegisterDefaultPlatform("VxWorks", mips64, g_vxWorksMips64);
}

Ref<Architecture> ppc32 = Architecture::GetByName("ppc");
Ref<Architecture> ppc64 = Architecture::GetByName("ppc64");
if (ppc32 && ppc64)
{
g_vxWorksPpc32 = new VxWorksPpcPlatform(ppc32, "vxworks-ppc32");
Platform::Register("vxworks", g_vxWorksPpc32);
BinaryViewType::RegisterDefaultPlatform("VxWorks", ppc32, g_vxWorksPpc32);
g_vxWorksPpc64 = new VxWorksPpcPlatform(ppc64, "vxworks-ppc64");
Platform::Register("vxworks", g_vxWorksPpc64);
BinaryViewType::RegisterDefaultPlatform("VxWorks", ppc64, g_vxWorksPpc64);
}

Ref<Architecture> riscv32 = Architecture::GetByName("rv32gc");
Ref<Architecture> riscv64 = Architecture::GetByName("rv64gc");
if (riscv32 && riscv64)
{
g_vxWorksRiscV32 = new VxWorksRiscVPlatform(riscv32, "vxworks-rv32gc");
Platform::Register("vxworks", g_vxWorksRiscV32);
BinaryViewType::RegisterDefaultPlatform("VxWorks", riscv32, g_vxWorksRiscV32);
g_vxWorksRiscv64 = new VxWorksRiscVPlatform(riscv64, "vxworks-rv64gc");
Platform::Register("vxworks", g_vxWorksRiscv64);
BinaryViewType::RegisterDefaultPlatform("VxWorks", riscv64, g_vxWorksRiscv64);
}

return true;
}
}
33 changes: 33 additions & 0 deletions view/vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)

project(view_vxworks)

if(NOT BN_INTERNAL_BUILD)
add_subdirectory(${PROJECT_SOURCE_DIR}/../.. ${PROJECT_BINARY_DIR}/api)
endif()

file(GLOB SOURCES
*.cpp
*.h)

if(DEMO)
add_library(view_vxworks STATIC ${SOURCES})
else()
add_library(view_vxworks SHARED ${SOURCES})
endif()

target_link_libraries(view_vxworks binaryninjaapi)

set_target_properties(view_vxworks PROPERTIES
CXX_STANDARD 17
CXX_VISIBILITY_PRESET hidden
CXX_STANDARD_REQUIRED ON
VISIBILITY_INLINES_HIDDEN ON
POSITION_INDEPENDENT_CODE ON)

if(BN_INTERNAL_BUILD)
plugin_rpath(view_vxworks)
set_target_properties(view_vxworks PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR}
RUNTIME_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR})
endif()
13 changes: 13 additions & 0 deletions view/vxworks/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2021-2024 Vector 35 Inc.

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.
Loading