Build 32bit client from scratch is not made clear

13 views
Skip to first unread message

ByteCrew

unread,
Oct 18, 2022, 11:25:16 AM10/18/22
to DynamoRIO Users
Hi, 
I'm trying to rebuild my client in 32-bit. In my root directory I only have CMakeLists.txt and the C source code of my client.

The only difference between my x64-related CMakeLists file are the strings  

set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_FLAGS -m32)

after the usual cmake <...> everything goes fine but after that when I open my visual studio files the target is still x64 and even if I add Win32/x86 platforms the build fails. Can you please explain in a more straightforward way how to build x86 clients? The info in this page are not so intuitive to follow.

Thank you.

Derek Bruening

unread,
Oct 18, 2022, 3:19:46 PM10/18/22
to ByteCrew, DynamoRIO Users
I'm confused by your reference to "-m32" but then mentioning Windows: which compiler and platform is this?  And please include which cmake generator is being used as that is critical on Windows.

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/4c28bd86-46d8-42d9-9ffe-d12a6d20b1d2n%40googlegroups.com.
Message has been deleted
Message has been deleted

ByteCrew

unread,
Oct 19, 2022, 6:35:05 AM10/19/22
to DynamoRIO Users
Yep, sorry for the missing info. By the way I'm on Windows major 19044, and I generate the cmake with cmake command from VS 2022 v17.3.6, I don't know if that's the info about the generator. 
Anyway, I've managed to get the 32bit of my dll by specifying -A Win32 on the command line while using cmake to generate the project files. 

All of this because I'm trying to instrument an application that is 32-bit and, in the first place, I thought that my x64-built dll was the problem but even now with my x86-built dll I'm getting the error "Target process <my\exe\path> is for the wrong architecture>". I've tried both x64 and x86 dll build but still I'm not able to spawn the instrumented process. Any hints?

Derek Bruening

unread,
Oct 19, 2022, 12:45:58 PM10/19/22
to ByteCrew, DynamoRIO Users
This is not really a DynamoRIO question: this is a CMake question.  You have to tell CMake to generate 32-bit.  For recent CMake versions it's "-A Win32" on a 64-bit host; for older versions the generator controls it completely.  The -m32 flag is only valid for gcc or clang, not the Visual Studio compiler.

Please consider submitting a pull request to add more configuration command line examples to the DynamoRIO documentation if you think that will be helpful to other users.

On Wed, Oct 19, 2022 at 4:49 AM ByteCrew <strozz...@gmail.com> wrote:
Yep, sorry. The platform is Windows (major 19044). I use cmake command from the VisualStudio package to generate my Lists file. I've compiled my client for x64 with the same settings (cmake + visual studio solution building) and now i want to do the exact same thing to have the x86 ver. 
The reason why I wrote those two flags in my CMakeLists.txt is because they were the only documented working reference to something that would make me able to compile 32-bit, that'it. What's the problem with the "-m32" flag? 

Il giorno martedì 18 ottobre 2022 alle 21:19:46 UTC+2 Derek Bruening ha scritto:
Reply all
Reply to author
Forward
0 new messages