ELFinfo
What
is it?
ELFinfo is a small utility for showing information about ELF files
What can it do?
It can show information about which machine an ELF file has been compiled for, if it's stripped or not, if it's big or little endian and which compiler and version has been used to compile the file.
It can detect compiler version for files compiled with the Go, GCC, OCaml or FPC compilers.
Example
Running this command:
elfinfo -l /usr/bin/ls
Gives this output:
/usr/bin/ls: stripped=true, compiler=GCC 6.3.1, byteorder=LittleEndian, machine=Advanced Micro Devices x86-64
The details will be different for other platforms.
Why?
- It only shows the most basic of information about ELF files.
- It can show which compiler was used for compiling a binary, even after it has been stripped.
- It aims to solve a tiny problem properly instead of a thousand problems halfway, in true UNIX-spirit.
- The methods for retrieving the compiler version for exectuables are different for Go, GCC, OCaml and FPC. ELFinfo handles all three.
- Discovering the GCC version number from an executable may involve using the string command and look for the first string that pops up and looks like a version number. ELFinfo only looks at specific sections in the ELF file.
Which arguments are supported?
- -v or --version for version information.
- -h or --help for help output.
- -c or --compiler together with a filename for only detecting the compiler name and version.
- Or only a filename as the first argument, for displaying various information about the ELF.
Source code and bug tracker
The source and issue tracker is available at
GitHub.
git clone git://github.com/xyproto/elfinfo.git
Installation
64-bit Linux
The following commands downloads the latest binary release from GitHub and installs it:
cd /tmp
curl -LO https://github.com/xyproto/elfinfo/releases/download/1.2.2/elfinfo
sudo install -Dm755 elfinfo /usr/bin/elfinfo
Commands will be slightly different or macOS or BSD.
As a Go script
This requires a working Go interpreter in /usr/bin/go:
cd /tmp
curl -LO https://raw.githubusercontent.com/xyproto/elfinfo/1.2.2/main.go
sudo install -Dm755 main.go /usr/bin/elfinfo.go
echo -e '#!/bin/sh\n/usr/bin/go run /usr/bin/elfinfo.go "$@"' > elfinfo.sh
sudo install -Dm755 elfinfo.sh /usr/bin/elfinfo
Commands will be slightly different on macOS or BSD.
Using the latest development version
go get -u github.com/xyproto/elfinfo
Downloads
Alexander F. Rødseth, 2023