首先,mac系统下的文件格式是mach-o,并不支持objdump和readelf;
退而求其次,使用brew update && brew install binutils
,然后用greadelf
和gobjdump
;
注意,使用使用brew update && brew install binutils
会有如下提示:
binutils is keg-only, which means it was not symlinked into /usr/local,
because because Apple provides the same tools and binutils is poorly supported on macOS.
If you need to have binutils first in your PATH run:
echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> ~/.bash_profile
For compilers to find binutils you may need to set:
export LDFLAGS="-L/usr/local/opt/binutils/lib"
export CPPFLAGS="-I/usr/local/opt/binutils/include"