From d4e3174ce985c9f64b6321da165baa1507c31dd1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 08:53:35 +0000 Subject: [PATCH 1/4] Initial plan From 6a5b17b276b09a415283ae2f6db0e3e02be6368a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 09:07:27 +0000 Subject: [PATCH 2/4] Initial plan: add --arch option for cross-platform --list-api --- tools-cfg.cmake | 86 +++++++++++++++++++++++++++++++++++++ tools/system/CMakeLists.txt | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 tools-cfg.cmake diff --git a/tools-cfg.cmake b/tools-cfg.cmake new file mode 100644 index 00000000..1ee55e8a --- /dev/null +++ b/tools-cfg.cmake @@ -0,0 +1,86 @@ +#================================================================================================================================ +# Default tools configuration +#================================================================================================================================ + +# +# Default configuration options +# +set(DMOD_USE_STDLIB ON ) +set(DMOD_USE_STDIO ON ) +set(DMOD_USE_ASSERT ON ) +set(DMOD_USE_PTHREAD ON ) +set(DMOD_USE_MMAN ON ) +set(DMOD_BUILD_TESTS ON ) +set(DMOD_BUILD_EXAMPLES ON ) +set(DMOD_BUILD_TOOLS ON ) + +# +# Toolchain configuration +# +if(NOT DEFINED COMPILER_PATH) + set(COMPILER_PATH "") +endif() +if(NOT DEFINED CROSS_COMPILE) + set(CROSS_COMPILE "") +endif() + + + +# +# Toolchain configuration +# +if(NOT DEFINED CROSS_COMPILE) + set(CROSS_COMPILE "") +endif() + +find_program(GCC ${CROSS_COMPILE}gcc) +if(NOT GCC) + message(FATAL_ERROR "GCC compiler not found") +endif() + +find_program(GXX ${CROSS_COMPILE}g++) +if(NOT GXX) + message(FATAL_ERROR "G++ compiler not found") +endif() + +find_program(LD ${CROSS_COMPILE}ld) +if(NOT LD) + message(FATAL_ERROR "Linker not found") +endif() + +find_program(OBJDUMP ${CROSS_COMPILE}objdump) +if(NOT OBJDUMP) + message(FATAL_ERROR "objdump not found") +endif() + +find_program(OBJCOPY ${CROSS_COMPILE}objcopy) +if(NOT OBJCOPY) + message(FATAL_ERROR "objcopy not found") +endif() + +find_program(AR ${CROSS_COMPILE}ar) +if(NOT AR) + message(FATAL_ERROR "ar not found") +endif() + +find_program(SIZE ${CROSS_COMPILE}size) +if(NOT SIZE) + message(FATAL_ERROR "size not found") +endif() + +# ============================================================================== +# CMake Configuration +# ============================================================================== +set(CMAKE_C_COMPILER "${GCC}" CACHE STRING "C compiler") +set(CMAKE_CXX_COMPILER "${GXX}" CACHE STRING "C++ compiler") +set(CMAKE_LINKER "${LD}" CACHE STRING "Linker") +set(CMAKE_OBJDUMP "${OBJDUMP}" CACHE STRING "Objdump") +set(CMAKE_OBJCOPY "${OBJCOPY}" CACHE STRING "Objcopy") +set(CMAKE_SIZE "${SIZE}" CACHE STRING "Size") +set(CMAKE_AR "${AR}" CACHE STRING "Archiver") +set(MAKE make CACHE STRING "Make") +set(MKDIR mkdir CACHE STRING "Mkdir") +set(RM rm CACHE STRING "Rm") +set(CMAKE_C_FLAGS "-Wall -Werror -std=c11 ${CPUCONFIG_CFLAGS}") +set(CMAKE_CXX_FLAGS "-Wall -Werror -std=c++17 ${CPUCONFIG_CXXFLAGS}") +set(CMAKE_LFLAGS "${CPUCONFIG_LDFLAGS}") \ No newline at end of file diff --git a/tools/system/CMakeLists.txt b/tools/system/CMakeLists.txt index 79946d02..2127e694 100644 --- a/tools/system/CMakeLists.txt +++ b/tools/system/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(todmfc) add_subdirectory(todmp) add_subdirectory(todmd) add_subdirectory(todmm) -add_subdirectory(dmf-get) +#add_subdirectory(dmf-get) add_subdirectory(dmf-man) add_subdirectory(whereisdmf) add_subdirectory(mkdmrpkg) \ No newline at end of file From 020b2def55390988bca167676cf2d24ca54a7dae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 09:14:04 +0000 Subject: [PATCH 3/4] feat: add --arch option to dmod_loader for cross-platform --list-api --- examples/system/dmod_loader/main.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/examples/system/dmod_loader/main.c b/examples/system/dmod_loader/main.c index 09d6e8e5..70765a4c 100644 --- a/examples/system/dmod_loader/main.c +++ b/examples/system/dmod_loader/main.c @@ -664,7 +664,7 @@ static void PrintModuleApiList( Dmod_Context_t* context ) // ----------------------------------------- void PrintUsage( const char* AppName ) { - printf("Usage: %s [--module ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); + printf("Usage: %s [--module ] [--arch ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); } // ----------------------------------------- @@ -677,12 +677,14 @@ void PrintHelp( const char* AppName ) printf("-- Dynamic Module Loader ver. " DMOD_VERSION_STRING " --\n\n"); printf("The DMOD is a dynamic module loader that allows to load and unload modules\n"); printf("This is an example application that uses the DMOD system\n\n"); - printf("Usage: %s [--module ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); + printf("Usage: %s [--module ] [--arch ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); printf("Options:\n"); printf(" -h, --help Print this help message\n"); printf(" -v, --version Print version information\n"); printf(" --info Print header information from a dmf/dmfc/dmp file without running it\n"); printf(" --list-api Load the module and print its input/output API list, then exit\n"); + printf(" --arch Architecture name for module name lookup (default: current arch)\n"); + printf(" Use with --list-api to inspect modules built for other platforms\n"); printf(" --module Specify which module to load from a DMP package\n"); printf(" --args Arguments to pass to the application module\n"); printf(" --debug [elf_path] Debug mode: pause after load, show addresses\n"); @@ -711,6 +713,7 @@ void PrintHelp( const char* AppName ) printf(" %s my-package.dmp --info # Print DMP package info\n", AppName); printf(" %s my-app.dmf --list-api # Print module input/output API list\n", AppName); printf(" %s my-package.dmp --module my_module --list-api # Print API list of a module in a package\n", AppName); + printf(" %s difs --list-api --arch armv7-cortex-m7 # Print API list of a module for another arch\n", AppName); printf(" %s my-app.dmf --stack # Stack analysis with default 1 MB stack\n", AppName); printf(" %s my-app.dmf --stack 2M # Stack analysis with 2 MB stack\n", AppName); printf(" %s my-app.dmf --stack 512k --stack-timeout 5 # Stack analysis, 512 KB, 5 s timeout\n", AppName); @@ -751,6 +754,7 @@ int main( int argc, char *argv[] ) // Parse arguments const char* pathOrName = argv[1]; const char* moduleName = NULL; + const char* archName = NULL; const char* debugElfPath = NULL; int appArgc = 0; char** appArgv = NULL; @@ -767,6 +771,7 @@ int main( int argc, char *argv[] ) int debugIndex = -1; int stackIndex = -1; int stackTimeoutIndex = -1; + int archIndex = -1; for( int i = 2; i < argc; i++ ) { if( strcmp( argv[i], "--module" ) == 0 ) @@ -791,6 +796,10 @@ int main( int argc, char *argv[] ) { listApiMode = true; } + else if( strcmp( argv[i], "--arch" ) == 0 ) + { + archIndex = i; + } else if( strcmp( argv[i], "--stack" ) == 0 ) { stackMode = true; @@ -866,6 +875,18 @@ int main( int argc, char *argv[] ) moduleName = argv[moduleIndex + 1]; } + // Get architecture name if --arch flag was provided + if( archIndex != -1 ) + { + if( argc <= archIndex + 1 ) + { + printf("Error: --arch flag requires an architecture name\n"); + PrintUsage( argv[0] ); + return -1; + } + archName = argv[archIndex + 1]; + } + // Prepare arguments to pass to the module // We need to construct argv array with pathOrName as argv[0] // followed by any arguments after --args @@ -907,7 +928,7 @@ int main( int argc, char *argv[] ) { // It's a module name, use Dmod_LoadModuleByName printf("Loading module by name: %s\n", pathOrName); - if( !Dmod_FindModuleFile( pathOrName, DMOD_ARCH, filePath, sizeof(filePath) ) ) + if( !Dmod_FindModuleFile( pathOrName, archName, filePath, sizeof(filePath) ) ) { printf("Cannot find module file for module name: %s\n", pathOrName); Dmod_Free( appArgv ); From db77cb8c21e4bf73508ced97ae9eade25315bbe3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 09:27:21 +0000 Subject: [PATCH 4/4] fix: skip arch check in Dmod_FindModuleFile when crossplatform mode is enabled --- examples/system/dmod_loader/main.c | 27 +++------------------------ src/system/dmod_system.c | 6 +++--- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/examples/system/dmod_loader/main.c b/examples/system/dmod_loader/main.c index 70765a4c..09d6e8e5 100644 --- a/examples/system/dmod_loader/main.c +++ b/examples/system/dmod_loader/main.c @@ -664,7 +664,7 @@ static void PrintModuleApiList( Dmod_Context_t* context ) // ----------------------------------------- void PrintUsage( const char* AppName ) { - printf("Usage: %s [--module ] [--arch ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); + printf("Usage: %s [--module ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); } // ----------------------------------------- @@ -677,14 +677,12 @@ void PrintHelp( const char* AppName ) printf("-- Dynamic Module Loader ver. " DMOD_VERSION_STRING " --\n\n"); printf("The DMOD is a dynamic module loader that allows to load and unload modules\n"); printf("This is an example application that uses the DMOD system\n\n"); - printf("Usage: %s [--module ] [--arch ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); + printf("Usage: %s [--module ] [--args ] [--debug [elf_path]] [--info] [--list-api] [--stack [size]] [--stack-timeout ]\n", AppName); printf("Options:\n"); printf(" -h, --help Print this help message\n"); printf(" -v, --version Print version information\n"); printf(" --info Print header information from a dmf/dmfc/dmp file without running it\n"); printf(" --list-api Load the module and print its input/output API list, then exit\n"); - printf(" --arch Architecture name for module name lookup (default: current arch)\n"); - printf(" Use with --list-api to inspect modules built for other platforms\n"); printf(" --module Specify which module to load from a DMP package\n"); printf(" --args Arguments to pass to the application module\n"); printf(" --debug [elf_path] Debug mode: pause after load, show addresses\n"); @@ -713,7 +711,6 @@ void PrintHelp( const char* AppName ) printf(" %s my-package.dmp --info # Print DMP package info\n", AppName); printf(" %s my-app.dmf --list-api # Print module input/output API list\n", AppName); printf(" %s my-package.dmp --module my_module --list-api # Print API list of a module in a package\n", AppName); - printf(" %s difs --list-api --arch armv7-cortex-m7 # Print API list of a module for another arch\n", AppName); printf(" %s my-app.dmf --stack # Stack analysis with default 1 MB stack\n", AppName); printf(" %s my-app.dmf --stack 2M # Stack analysis with 2 MB stack\n", AppName); printf(" %s my-app.dmf --stack 512k --stack-timeout 5 # Stack analysis, 512 KB, 5 s timeout\n", AppName); @@ -754,7 +751,6 @@ int main( int argc, char *argv[] ) // Parse arguments const char* pathOrName = argv[1]; const char* moduleName = NULL; - const char* archName = NULL; const char* debugElfPath = NULL; int appArgc = 0; char** appArgv = NULL; @@ -771,7 +767,6 @@ int main( int argc, char *argv[] ) int debugIndex = -1; int stackIndex = -1; int stackTimeoutIndex = -1; - int archIndex = -1; for( int i = 2; i < argc; i++ ) { if( strcmp( argv[i], "--module" ) == 0 ) @@ -796,10 +791,6 @@ int main( int argc, char *argv[] ) { listApiMode = true; } - else if( strcmp( argv[i], "--arch" ) == 0 ) - { - archIndex = i; - } else if( strcmp( argv[i], "--stack" ) == 0 ) { stackMode = true; @@ -875,18 +866,6 @@ int main( int argc, char *argv[] ) moduleName = argv[moduleIndex + 1]; } - // Get architecture name if --arch flag was provided - if( archIndex != -1 ) - { - if( argc <= archIndex + 1 ) - { - printf("Error: --arch flag requires an architecture name\n"); - PrintUsage( argv[0] ); - return -1; - } - archName = argv[archIndex + 1]; - } - // Prepare arguments to pass to the module // We need to construct argv array with pathOrName as argv[0] // followed by any arguments after --args @@ -928,7 +907,7 @@ int main( int argc, char *argv[] ) { // It's a module name, use Dmod_LoadModuleByName printf("Loading module by name: %s\n", pathOrName); - if( !Dmod_FindModuleFile( pathOrName, archName, filePath, sizeof(filePath) ) ) + if( !Dmod_FindModuleFile( pathOrName, DMOD_ARCH, filePath, sizeof(filePath) ) ) { printf("Cannot find module file for module name: %s\n", pathOrName); Dmod_Free( appArgv ); diff --git a/src/system/dmod_system.c b/src/system/dmod_system.c index b59b2db7..87c1413c 100644 --- a/src/system/dmod_system.c +++ b/src/system/dmod_system.c @@ -549,6 +549,7 @@ bool Dmod_FindModuleFile(const char* ModuleName, const char* ArchName, char* out ArchName = DMOD_ARCH; } + bool crossplatform = Dmod_IsCrossplatformMode(); Dmod_SearchNode_t* searchNode = Dmod_Hlp_PrepareModulesSearchNodes(); Dmod_SearchNode_t* currentNode = searchNode; while( currentNode != NULL ) @@ -560,13 +561,12 @@ bool Dmod_FindModuleFile(const char* ModuleName, const char* ArchName, char* out ( PrepareModulePath(repoDir, ModuleName, false, outFilePath, MaxLength) && Dmod_FileAvailable(outFilePath) - && CheckModuleArchitecture(outFilePath, ArchName) + && (crossplatform || CheckModuleArchitecture(outFilePath, ArchName)) ) || ( PrepareModulePath(repoDir, ModuleName, true, outFilePath, MaxLength) && Dmod_FileAvailable(outFilePath) - && CheckModuleArchitecture(outFilePath, ArchName - ) + && (crossplatform || CheckModuleArchitecture(outFilePath, ArchName)) ) ) {