I am wondering if there is a simple way in Linux, or maybe an existing open source project that will allow me to provide it a binary or firmware image and it will return both the architecture (aarch64, armv7-eabihf, armv7m, etc.) and the libc type (glibc, musl, uclibc) used?
My hope is to be able to script a way to automatically grab the correct qemu-system-* image (e.g. https://azeria-labs.com/emulate-raspberry-pi-with-qemu/) for device emulation as well as the correct cross-compile toolchain (https://toolchains.bootlin.com/) based on either a single binary to emulate (ideal), or a full firmware image (less ideal).
Current understanding - Full architecture may be able to be "mapped" to toolchains.bootlin.com and qemu-system-* architectures based on output of the file
command, maybe? Also, I know there are lots of answers here on SO that show similar answers for this question, but assume you have some kind of system access and can run commands like "ldd". I'm looking for a solution that is based purely on static analysis of either a binary or if necessary a firmware image of an unknown device.