VOGONS

Common searches


First post, by BEEN_Nath_58

User metadata
Rank l33t
Rank
l33t

I am trying to search for a program which can tell what CPU features a "program X" requires. Till now my search terms have been unsuccessful in finding one. Can Vogons tell what to use or how to list CPU features needed for "program X"??

previously known as Discrete_BOB_058

Reply 1 of 5, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie

it depends what the developer of program X says it needs. otherwise you'd have to analyse down to the opcodes to see but even then you dont know the execution path and some app could have 386 opcode that never use them if its on a 286.... so... no... you cant tell.

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 2 of 5, by mr.cat

User metadata
Rank Member
Rank
Member

For simple cases, "objdump -d" or equivalent (plus some grepping) might suffice.

There are lots of projects that do some kind of platform detection on a file, but it's usually fairly limited (for the reasons mentioned above).
For example, Ghidra and Cutter need to know what kind of platform they're dealing with or their results would be just gibberish.
I don't think they go as far as trying to detect the toolchain that was used to build the .exe, but I think I've seen some project trying to accomplish even that.
EDIT: Perhaps I was thinking of this one.
The toolchain version might give a clue about the intended CPU target (e.g. No SSE2 support if the compiler is so old it only knows SSE)

Here's a few that try to do ISA detection:
https://github.com/kairis/isadetect
https://github.com/krsh/seer
https://github.com/airbus-seclab/cpu_rec/

So just throw some AI at the problem and the results will magically appear? The modern approach I guess 😁
Perhaps the code could be extended to produce a more fine-grained opcode detection.

Last edited by mr.cat on 2022-06-16, 22:04. Edited 2 times in total.

Reply 3 of 5, by bakemono

User metadata
Rank Oldbie
Rank
Oldbie

There are ways to identify different executable types and distinguish between 64/32/16-bit based on information in program headers, etc. but if you mean something like "does it need SSE3" then there isn't really a way to know without running the program. One program that has SSE3 opcodes in it might try to detect whether the CPU supports it and use an alternate code path, while another one doesn't do the detection so it just crashes with an illegal instruction. Hard to tell the difference without stepping through the code.

again another retro game on itch: https://90soft90.itch.io/shmup-salad

Reply 4 of 5, by BEEN_Nath_58

User metadata
Rank l33t
Rank
l33t
BloodyCactus wrote on 2022-06-13, 12:15:

it depends what the developer of program X says it needs. otherwise you'd have to analyse down to the opcodes to see but even then you dont know the execution path and some app could have 386 opcode that never use them if its on a 286.... so... no... you cant tell.

That's an issue I encountered. A program I ran had the mmx opcode but it never used mmx.

mr.cat wrote on 2022-06-13, 18:12:
For simple cases, "objdump -d" or equivalent (plus some grepping) might suffice. […]
Show full quote

For simple cases, "objdump -d" or equivalent (plus some grepping) might suffice.

There are lots of projects that do some kind of platform detection on a file, but it's usually fairly limited (for the reasons mentioned above).
For example, Ghidra and Cutter need to know what kind of platform they're dealing with or their results would be just gibberish.
I don't think they go as far as trying to detect the toolchain that was used to build the .exe, but I think I've seen some project trying to accomplish even that.

Here's a couple of projects that try to do ISA detection:
https://github.com/kairis/isadetect
https://github.com/krsh/seer

So just throw some AI at the problem and the results will magically appear? The modern approach I guess 😁
Perhaps the code could be extended to produce a more fine-grained opcode detection.

Little complex than what I wanted, but if an easier solution isn't there, I will try with this

bakemono wrote on 2022-06-13, 21:25:

There are ways to identify different executable types and distinguish between 64/32/16-bit based on information in program headers, etc. but if you mean something like "does it need SSE3" then there isn't really a way to know without running the program. One program that has SSE3 opcodes in it might try to detect whether the CPU supports it and use an alternate code path, while another one doesn't do the detection so it just crashes with an illegal instruction. Hard to tell the difference without stepping through the code.

I was trying to determine if a program needed SSE or SSE2. The developer isn't sure of it either so I wanted to check. I was just wondering if it's possible to "hide" a CPU instruction for a program.

previously known as Discrete_BOB_058

Reply 5 of 5, by mr.cat

User metadata
Rank Member
Rank
Member

Qemu has the -cpu switch which can be used to set CPU features, that may sometimes help. Run qemu with "-cpu help" to see what's available.
I actually used it some time ago to track down a bug that only manifested with SSE4.1.
TCG plugins are yet another possibility, take a look at contrib/plugins/howvec.c.

Although with qemu (unless you're using user mode) you'll be switching the CPU features for the whole guest OS and it's a lengthy manual process anyway.
I think most other emus only provide a CPU type in the config rather than the individual feature flags, but that may helpful too.
SSE2 was introduced with P4 though, probably not too many emus available for that.

EDIT: This thread has some more discussion (and solutions):
https://superuser.com/questions/726395/how-to … or-avx-on-linux

EDIT2: The given solution elfx86exts seems quite close to what you were asking. Won't uncover any hidden code though.
Btw it's Rust-based, so running "cargo build" will fetch ~360MB worth of dependencies.