OpenBSD file(1)
The file utility tests each argument and attempts to determine its type. Three sets of tests are performed:
1. Filesystem tests, for example if a file is empty, or a special file such as a socket or named pipe (FIFO).
2. “Magic” tests for data in particular fixed formats. These are loaded from the /etc/magic file (or ~/.magic instead if it exists and file is not running as root). The file format is described in magic(5).
3. Tests for text files such as plain ASCII or C programming language files.
The first test which succeeds causes the file type to be printed. The type will often contain one of the words text (contains only printing characters and is probably safe to read on an ASCII terminal), executable (the file contains a compiled executable program) or data meaning anything else.
The object is bin/file.exe compiled for the ABI.
$ get-object CommonsBase_FileMagic.File@7.8.50407 -s Release.target_abi -d ${RUNTIME}/File-7.8.50407
\test(pass)
\dk.object(abi: "Release.Darwin_arm64", value-id: "orw5ufcbtpfhoolmn3edctuks5slcu6mpsekz4ju5iv2zviwpspjq")
\dk.object(abi: "Release.Darwin_x86_64", value-id: "ojnr3jm3fxbo5xj3nkita2kbymekuj2zjmmsdncpupwvvk6wdizsa")
\dk.object(abi: "Release.Linux_arm64", value-id: "o5avhm2mcs3q527pe3vv5yownl2orfxu7ak3bpy7kvjve5iwpr6gq")
\dk.object(abi: "Release.Linux_x86", value-id: "oszw7iqompkbdpr46nmd2mtefnnej4bdwqezpzpalqvgr232jyizq")
\dk.object(abi: "Release.Linux_x86_64", value-id: "oye5vhgtd74nhaml2opt5nxz67oypdq3g34rjtpe4tmhnhncqbjwa")
\dk.object(abi: "Release.Windows_arm64", value-id: "ov4aynftw2g2st7xt3qvoxtmjgc7gndpytgdixr4srctzx75izkmq")
\dk.object(abi: "Release.Windows_x86", value-id: "ogfs7l4ljjrzdomjs6dgmgfal4mrzeo4tbeyrdjaitb6bxd2v5vza")
\dk.object(abi: "Release.Windows_x86_64", value-id: "oteegaquqsej3mxqqnnanbgg7mocda64itjjdcq4tswv4jrr5oaiq")\;
Running bin/file.exe on itself (the bin/file.exe) will tell us what CPU architecture and operating system
the executable was compiled for.
$ run-object CommonsBase_FileMagic.File@7.8.50407 -s Release.execution_abi -m ./bin/file.exe -e bin/file.exe --
> -b $(get-object CommonsBase_FileMagic.File@7.8.50407 -s Release.target_abi -d : -e file.exe)/bin/file.exe
\test(pass)
\dk.target(abi: "Darwin_arm64")[Mach-O 64-bit executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
]
\dk.target(abi: "Darwin_x86_64")[Mach-O 64-bit executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
]
\dk.target(abi: "Linux_arm64")[ELF 64-bit LSB executable, aarch64, version 1
]
\dk.target(abi: "Linux_x86")[ELF 32-bit LSB executable, Intel i386, version 1 (SYSV)
]
\dk.target(abi: "Linux_x86_64")[ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
]
\dk.target(abi: "Windows_arm64")[PE32+ executable for MS Windows 6.00 (console),, 13 sections
]
\dk.target(abi: "Windows_x86")[PE32 executable for MS Windows 6.00 (console),, 15 sections
]
\dk.target(abi: "Windows_x86_64")[PE32+ executable for MS Windows 6.00 (console),, 14 sections
]\;