smx-smx / ASMTool

Firmware dumper and various utilities for ASMedia USB Controllers and related firmware
57 stars 10 forks source link

Probably doing something wrong but I'm getting mixed 64 and 32 bit binaries on linux. #10

Open hanetzer opened 10 months ago

hanetzer commented 10 months ago

So. The x370 chipset on ryzen is very much like asmedia stuff, and was hoping to poke it a bit in order to assist my port of coreboot to 'Asrock X370 Killer Sli/AC' (kind of in a working state; more to be done).

By issuing dotnet build I get a 64-bit ELF for AsmTool but the dlls come out as 32 bit. Attempting to run AsmTool nets me the following error:

Unhandled exception. System.BadImageFormatException: Could not load file or assembly '~/ASMTool/AsmTool/bin/Debug/net6.0/AsmTool.dll'. An attempt was made to load a program with
an incorrect format.

File name: '~/ASMTool/AsmTool/bin/Debug/net6.0/AsmTool.dll'
Aborted (core dumped)

libAsmIOLinux.so is compiled and in the directory next to AsmTool (it is also a 64-bit ELF)

rhn commented 10 months ago

I have the same issue. I used the CI dockerfile and commands, but the created artifact is unuseable.

voltagex commented 10 months ago

In the CMake files, there's a line that clears the target platform but it doesn't get set again on Linux.

Theoretically

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4da64d4..1787fce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ ADD_DOTNET(${CMAKE_SOURCE_DIR}/AsmTool.sln
 )

 if(UNIX)
+       set(target_platform PLATFORM x64)
        enable_language(C)
        add_subdirectory(AsmTool/Linux)
        add_dependencies(AsmTool_sln asmIoLinux)

should be enough to fix it, but

voltagex@BeeMovie:~/src/ASMTool/build/out$ file libasmIoLinux.so
libasmIoLinux.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=16e6d63384efb4239eb312f502242296346eae03, not stripped
voltagex@BeeMovie:~/src/ASMTool/build/out$ file AsmTool
AsmTool: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=10540531054f88680224e7bf543dc2dbef55c014, for GNU/Linux 2.6.32, stripped
voltagex@BeeMovie:~/src/ASMTool/build/out$ file AsmTool.dll
AsmTool.dll: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows, 3 sections

@smx any idea what's going on here?