Retrieve the triple/target from the elf file


in order to disassmble an elf file I’m using llvm-objdump
it needs to get triple as an input.
is there a tool/way to get this triple from the elf file?
can the objdump do it automatically?


It depends on how much metadata there is in the ELF file. At a minimum the ELF Header can tell the machine and endianness (ELF Header). It isn’t enough to tell you which sub-architecture, vendor, OS or ABI.

In some cases there is more metadata available. All 32-bit ELF relocatable objects and many executables have a Build Attributes section that llvm-objdump can use to get more information. Often enough to recreate enough of the triple to get correct disassembly. This type of metadata is platform specific, and isn’t always available though.